Pregunta

I am trying to use the PageViewController with different layouts but I dont know how to accomplish that. Currently Im using the page-based application provided as a template for new projects in XCode 5 for iOS. This application uses the same view controller for all pages, and I want different pages. Is this even possible? And how can I add a different view while using this template and storyboard. I couldnt find any tutorials that uses storyboard and adding different pages.

I have also tried UIScrollView with paging enable. But those tutorials I found required to turn off auto layout in settings, such as this one: http://www.iosdevnotes.com/2011/03/uiscrollview-paging/. And that is not the correct way of doing it.

Since I havent found any examples, I start to wonder if this is even possible to do in a simple way?

¿Fue útil?

Solución

I don't think this is possible using storyboards in the straightforward way you want, but it can be achieved with relative ease. You can create all your different view controllers in the storyboard (these will serve as pages) and give them identifiers. Now in code, have the view controller that displays the page view controller be its data source.

Now, in – pageViewController:viewControllerBeforeViewController: and – pageViewController:viewControllerAfterViewController:, implement logic that decides which view controller to load, and use the storyboard's – instantiateViewControllerWithIdentifier: to return an appropriate view controller.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top