Is there a way to prevent swiping to one specific page in UIPageViewController
In my case, I need the left page just to be accessible sometimes,
Thanks!
No.
You will need to set up your page view controller without the page in question, and then add it when you want it to be available.
I would suggest changing your design. Page view controllers aren't intended to handle a case where the set of pages displayed changes. The real world analogy is a book where a page appears sometimes and not others. It doesn't make sense.
Instead you might want to present a modal view controller when you want this special-case VC to be available.
Related
I want to create a page where the user can enter his/her details and then swipe through the next couple of pages which will be tutorial screens. I want the page controller to be present through the tutorial part and the part where the user enters their details. Almost all the tutorials I found used images and page control in conjunction.
Initially i thought that i could do this using uipageview controller, but then i realized that you can only put in images for tutorials!? Correct me if I'm wrong.
So now I'm considering using a scroll view with page control, but I'm not entirely sure about how to go about doing this.
Could somebody shed some light on how this is possible?
Yes it's possible. From UIPageViewController reference guide:
A page view controller lets the user navigate between pages of
content, where each page is managed by its own view controller object.
Create a UIViewController with the login UI and logic then add it to the UIPageViewController.
Can anyone tell me how to maintain the state of a view even while navigating through different views. I have a main view controller that has some button interaction and label changes with those interactions and I want to maintain those states while the user navigates to different pages.
It is not a good idea to "save" ui object, it is instead better to save the data you want to use somewhere (like a file) and get it when needed
I want to build a app like this one named "next day" (here's some snapshots).
With swiping right, it goes to previous view controller witch shows one picture and the date. If i keep swiping, it'll switch view controller on and on. Please tell me what does the architecture look like and how to do that. Sorry for my broken English and thanks for your help!
UIPageViewController is exactly for this. You can either instantiate it directly or subclass it, but in both cases you need to provide a data source which conforms to <UIPageViewControllerDataSource> to dynamically provide a view controller for each page after setting an initial default page for the current day. You will need a way to keep track of your current page, which can be a property on your custom view controller subclass which you’ll be returning for each page.
I have a universal application with a list of items (loaded from a backend) and item details (loaded from a backend as well). Each view controller listens to the UIApplicationDidBecomeActiveNotification, so that the view is refreshed when the user (re-)opens the app. That works so far.
Now my problem. On iPad, I have a split view. So, when the user (re-)opens the app in landscape, both views are reloaded. If there is no connection to the backend, the user gets two alerts with Retry/Cancel options, one above the other. That is not what I want... I have one default item which does not require connection to the backend and I want to set it to be selected and to display its details in the detail view. Always when the originally selected item is missing in the master view.
What I have done so far... In my master view controller, I check whether the selected item is available after the refresh and if not, I update the selection and the detail view. This should solve the problem when the requests from the left and from the right pane are processed in the correct order. However, currently both view controllers get the UIApplicationDidBecomeActiveNotification and make asynchronous requests to the backend.
Has someone experience in refreshing split views? What would be the right way to solve my problem? I really don't want to introduce additional notifications/complexity. I hope, there is some standard way to reload the data.
Well, I found a solution.
I create for each view controller a property alertView and store there the alert view that is displayed. In viewWillDisappear, I dismiss this alert view. So, when the details for my default item are displayed to the right, the alert view of the "old" controller is dismissed and I have only one alert view.
It is for sure not the perfect solution and I would be happy if someone can give me a better one. But for now, that works fine.
There is something that bothers me about this concept of having table view controllers in a page view controller.
Yet, the customer wants separate pages with a table view in each page. It even makes sense in this case. However, I have not come across this before and something bothers me about it.
By the way, each row of a table will take a person to a detail view controller where the data can be edited.
I think if gesture recognizers are used that allow page transitions to happen via tapping or flicking, that could get in the way of the table rows.
I am going to check it out. However, my time is limited and I will have to bail quickly if this does not work out.
Anyone see gotchas on this and I should come up with another approach now? :)
update: Another approach could be a navigation controller containing tableview controllers.
For the basic case, there is no reason a PageViewController cannot contain a TableViewController