1

I am working on a book app that allows the user to flip through pages at the bottom of the screen. These buttons are Navigation Links and work perfectly, up until page 14. At page 14 the app screen goes blank. Is there some sort of limit on how many pages I can go through with Nav Links? If there is how can I get around that?

This is what I have for my navigation setup, it's the same on every page with the page numbers being the only thing that differs:

 HStack{
                            //previous page
                            NavigationLink(destination: aristotlesPoetics13()) {
                                Image(systemName: "arrowshape.left")
                                    .font(.system(size: 30))
                                    .foregroundColor(Color("yellowBeige"))
                                    .padding([.top, .trailing])
                            }
                            
                            //home
                            NavigationLink(destination: ContentView()) {
                                Image(systemName: "house")
                                    .font(.system(size: 30))
                                    .foregroundColor(Color("yellowBeige"))
                                    .padding([.top, .leading, .trailing])
                            }
                            //next page
                            NavigationLink(destination: aristotlesPoetics15()) {
                                Image(systemName: "arrowshape.right")
                                    .font(.system(size: 30))
                                    .foregroundColor(Color("yellowBeige"))
                                    .padding([.top, .leading])
                            }

I have tried restarting Xcode and simulating different iPhones but neither worked. I have also quadruple checked the pages to ensure that everything is spelled correctly and it is. When I start the iPhone simulation from page 14 and click onto page 15 I have no issues. When I click into the book from ContentView (my apps homepage) and navigate through the pages until I reach page 15 is when I have issues.

JakeW
  • 103
  • 1
  • 1
  • 4
  • 2
    I don’t think books are the intended use for NavigationLinks. I have not tried but 14 is better than about 3 layers that were available when SwiftUI first came out in 2019. I would rethink the approach. Also, your previous page setup is just creating a new page with the content of the previous it isn’t actually going back so you like have more issues than you are seeing. – lorem ipsum Dec 05 '22 at 02:11
  • @loremipsum what method would you recommend for navigation between pages in a book? I was looking at TabView but I don't think that's right – JakeW Dec 05 '22 at 02:43
  • 1
    Create your own NavigationView and TabView are just basic tools. I am sure if you Google you can find tutorials or other approaches. Maybe something like a stepper to control the page number and just have a single view that displays the current page. Having dozens, hundreds, and maybe thousands of navigation links or “tabs” isn’t viable performance wise. – lorem ipsum Dec 05 '22 at 03:11
  • You should come up with a generic page view that can display a page from your data model. Then all you need to do is change the index into the data model as you change pages. Your buttons just increment/decrement the index – Paulw11 Dec 05 '22 at 06:45

0 Answers0