Any reason a pageviewcontroller could not contain tableviewcontrollers? - ios

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

Related

prevent scroll to one page in pageviewcontroller

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.

swiping between records with UIScrollView

I'm trying to build a view where customers can swipe side to side between potentially thousands of records, so my thought was to use a UIScrollView with 3 view controllers to display the details, so there is always a view controller off screen to the left with the previous record and a view controller to the right with the next record.
What I need help with is the logic to move the view controllers around in the scroll view.
I've seen examples online but they mostly seem buggy, or they allocate 1 view controller for each piece of data they want to display, but obviously I don't want to put thousands of view controllers in memory.
Can anyone point me in the direction of a good solution for this situation?
I appreciate any help...
Check out the documentation for UIPageViewController, which can be initialized to scroll horizontally between its pages. Here's a tutorial if you need help getting started.

Multiple Segues to one ViewController with NavigationController?

i have one question about using multiple segues to one ViewController. Ill try to create an article management, so you can add/edit/delete articles.
When you add a new article you can choose between a maincategory and a subcategory, choose the article and then edit some inital values.
but if ill try to edit one of my selected articles, i would like to jump to the "latest" ViewController in navigation stack.
I thought i could easily create another segue to my last viewController, but ill always get an error when i try to load this segue (i guess this could be a problem with the existing NavigationController).
I could provide some code, but i dont know if this is a possible solution to solve such things - or is there a better way?
Thanks in advance.
You can, but the new segue should take you to a navigation controller that just contains the last view controller (as the root). In this way you are duplicating the normal situation but with only 1 view controller.
If you wanted to allow the last view controller to have a 'back' button which took you to some 'earlier' screens (if that makes any kind of sense in your app) then you would need to write some code. It's more likely that other screens should be accessed via bar button items or similar (which would also likely be done in code).

How to build a view controller container with infinite child controllers?

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.

Refresh split view

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.

Resources