Group Group Group Group Group Group Group Group Group

Your Second iOS and SwiftUI App · Modal Views | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5662524-your-second-ios-and-swiftui-app/lessons/11

Hi,
I habe a problem in this part. When I add NavigationView thru dragging from the Library, they give me this framework:
NavigationView {
NavigationLink(destination: navigation) {content}
}
then whatever i code in it, the color of codes are totally white.

fixed after restarted the computer, it’s weird.

1 Like

@listenerxdw Glad you fixed it. Cheers! :]

why we call the navigationBarTitle function and navigationBarItems function on the others view but not the NavigationView.

SwiftUI is designed that way so you can change the title based on what view is showing within the navigation view. For example, later on in the course, when TaskEditingView shows up, the title disappears. But you could give it a title too!

Hi I am having an issue, whenever I inserted the sheet I get this error:

Type ‘NewTaskView.Type’ cannot conform to ‘View’; only struct/enum/class types can conform to protocols

Why does this not work?

Sounds like you didn’t instantiate NewTaskView.Type, but instead, tried to use its metatype. What’s the line of code that generates the error?

I had the same problem and appeared to be two issues that resolved it.

  1. The code couldn’t see the NewTaskView. I had to move it out of the folder, let it be found then move back into the Views folder.

  2. “nmbs” keystrokes did not work. I instead type “navigationBaritems()” it should have been “navigationBarItems()” (capital i in items).

No idea why it wasn’t showing up.

I figured it out, I had put NewTaskView instead of NewTaskView() with parenthesis. That solved the problem.

EDIT: Never mind, realized 30sec after posting that I just had the title appended to the wrong View, oops :laughing:

When I added the title and image to the NavigationView, nothing shows up above the list.

Screenshot shows the SwiftUI preview, but it’s the same on my iPhone device.

1 Like