Refresh split view - ios

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.

Related

Saving the state of the collection view when view controller is changed

I am using a collection view to present the data loaded from firebase. I am not using any sort of embedded navigation controller, just the normal viewcontroller.
Now, whenever I change my view and come back, all data is reloaded and the controller starts from scratch. I actually want it to be on the cell it was left of and how it was left.
I have check plenty of articles and sources on the internet, but most of them are about the embedded navigation controller.
Can anyone guide me on how exactly can I achieve this without using the embedded navigation controller?
Please let me know if anymore information is required. I'll be quite prompt.
I thinks it depends on where you reload your collection view data. You said
Now, whenever I change my view and come back
Did you present your next view controller or push view controller from view controller where your collection view exists? if yes, you may use dismiss or pop view controller to come back.
When you come back to view controller where your collection view exists, viewWillAppear and viewDidAppear method will be called.
Did you fetch data from firebase in one of these method? if yes all the data will be reloaded unless you made boolean flag not to load again.
Hope this help you.

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.

How to implement the Facebook App iOS UI with Xcode Storyboard?

I'm trying to build an app that has lots of similarities to the Facebook App in terms of the "Storyboard". I'm tempted to do everything in code as I know best but I'd really like to figure out how to storyboard these more complicated UI's.
The Facebook App starts with a login view. When you log in, you get a tab view. In the main tab view, you have a table view. Within each table view are a user, post, and comment buttons which push to a new view.
So the way I am understanding it is we have UINavigationController with the .navigationBarHidden set to false. The first view controller here is the loginViewController. When the login button is pressed and the user is logged in, we performSegueWithIdentifier to a UITabBarController. The first tab is a UINavigationController with a UITableViewController as the first view controller. Clicking user, post, or comment pushes the appropriate view controller onto the NavigationController.
This all begins to seems a bit more complicated than just writing this all out in code. I'm also not even sure this implementation is correct with all these nested view controllers. I'm not sure this is all possible with storyboard as well: for example a navigation controller for pushing to comment, user, or post views doesn't seem possible with storyboard.
I'd like to know the correct way of implementing this kind of UI design. And should / could this be implemented using Storyboards?
Your design team may layout the app using a "storyboard" (physical objects -- not the digital version). Large apps are hard to piece all the little things together on a storyboard. Just too many wires going every which way.
Look at the FB app without internet access and you can see their basic building blocks easier. Its built in units (post at a time) that are added to a scrolled view. Search bar and menus at the top and buttons at the bottom with the scrolled view in the middle. The posts probably have some common base class with various types derived from it (picture, video, links, etc).
There is some sort of background process monitoring the position of the scroll view to dynamically load new stories if you get down within 1/3 of the way to the bottom. Within each post you can see the components if you look closely and think about what sort of block that is.

Any reason a pageviewcontroller could not contain tableviewcontrollers?

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

Programmatically load the initial view controller from storyboard IOS5

I am creating a login type functionality for my iphone app. I've laid the whole thing out in storyboard. I have set a condition that keeps the user logged in for a day. Then after that, the application should direct them to the initial view controller (a page where they have to enter login credentials).
I was planning on putting this logic in the AppDelegate (app did load). If there is a better place to put this logic, I'd be open to that. But how do i access and load the initial view controller in my storyboard?
The reason I can't just load a segue to this initial view, is because I won't necessarily know where the user last left the application. And i don't want to create individual segues from each view back to the initial view.
Thanks!
EDIT! In response to Luis's answer
Okay, great! I added a navigation controller at the beginning of my starboard, like the first character suggested. Now, I'd like to go back to the navigation controller every time I open, or re-open the app, so that the navigation controller's logic executes. Thanks
Read both of the answers provided for this question, the first approach is easier but you have to do what you just wrote you didn't, the second one is what you are looking for but its way more complicated.
iOS 5 storyboard, programmatically determine path

Resources