Learn Courses My Dashboard

iOS Foundation M4L15 Wrap Up Challenge


Could you check the BookContent view in your solution(Module 4 Final Challenge)? For me it is not working properly.
When I try to switch tab it is crashing. After I try it again the page number starts with 2 and now I can switch one page but when I try to switch to page 3 it crashes again.

See pictures:

After switch to page 2 it crashes and goes back to Staging view when I click Read Now again I see this:

It is still the first page with page 2 index.
Now I can switch to page 2 but not to page 3.

In iPad simulators it works. Only iPhone simulators have this bug.
I use Xcode 13.1 and test with iOS 15.0.

Thanks in advance

1 Like

Do you mean it crashes and the Simulator displays the device home screen or do you mean the App crashes back to the Home View where the list of books is shown?

No, not the simulator. The App crashes back to its previous view which is the staging view of the book.

Have you added the modifier .navigationViewStyle(.stack) to the closing brace of the NavigationView in your BookListView (or whatever you have called your initial view)?

Hi @takipeti90 and @Chris_Parker,

This solution is not updated in the provided solution project “Module 4 Final Challenge” files.
Xcode warns me with the following:

[LayoutConstraints] Unable to simultaneously satisfy constraints.

After adding your solution .navigationViewStyle(.stack) to the Navigation View it all works!

Maybe add a comment to why this is needed in Module 4 and update the code in the solution.

I’m trying to understand this error.
Reading through some documentation I understand that a “normal NavigationView” adds new views in new columns if the device supports it (big iPhones in landscape mode and iPads).
Otherwise they are stacked on top of each other.
Does this mean that the errors are caused by several layers of active navigation/buttons that are conflicting?
Using the stack viewstyle we force to only show a single top view and deactivating other layers?

But what if I want this behaviour on landscape mode on an iPhone?

Those errors/warnings that you are getting in the Console are not material to the bug in the way the App operates.

The challenge was created prior to the issues that arose in iOS 14.5 with the way a NavigationView behaves when using a NavigationLink. The behaviour that arose was as you noticed where the View bounces back after you swipe forward a page.

As you select each NavigationLink the presented page is added to a stack and you see the View on the top of the stack.

I don’t believe that it has to do with conflicts. It’s more to do with telling SwiftUI in this App case to treat the NavigationView as a stack as you navigate deeper into subsequent views. As you navigate back it pops the current View off the stack and displays the previous.

You would probably design your App differently to take advantage of that layout.

OK, Thanks for your explanation.