Mainly, my iphone application right now is a UIviewController with navigation buttons, logo, and title on the top of the screen. Inside this controller is a container view, which has an embedded navigation controller which leads to a series of table views that the user can navigate through. On the parent view, there is a back button that causes the inner navigaion controller to call popViewController and also updates the title of the screen on the outer view. This all works correctly, but when the user clicks the back button quickly, the naviagtion controller will already be in motion and “pop” again, but the title will update, causing the pages to become out of sync.
I have tried to block the back button and even used completion handlers, but nothing seems to work. Is there really no way for me to be able to prevent the back button from being clicked while the inner navigation controller is busy?
Related
This is a bit of a tricky one to explain here so I'm hoping the screenshot of the storyboard of the app I'm trying to build helps to clarify what I'm trying to do.
Basically the apps starts with a nav controller and table view, when you click on a cell in the table view you go to a tab bar controller with three tabs, each tab view has its own navigation controller and subsequently there is a navigation bar on each of them, so at this point there is a back button on all tab views which takes us back to the initial table view.
The first tab view simply has some text, the next has a table view with several table cells and the last has a map view with several markers. Both the table cell and the map markers link to a detail view via a navigation controller which shows more detailed information (both via named segues). It's at this point of clicking through to the detail view where the navigation is breaking, the detail page shows no navigation bar although it is there as the title text is set, but there is no back button and it seems that the navigation context / hierarchy has been broken here somehow. The appearance of the storyboard also reflects this as it shows no Back button on the navbar on the navigation controller or the Detail view.
Without initially getting into the code in any real way I am just trying to see if there is any significant reason why these type of structure / hierarchy is just now going to work. So, my main question is does this storyboard structure seem like the correct way to go about what I'm trying to do?
Here is the storyboard:
I have a storyboard with tab bar controller and one of the tabs segue to another view controller and so on as show in the picture.
I want to go to the page (3) programmatically in the stack while maintaining the stack of the tab bar controller .
Thanks in advance..enter image description here
This one's a little tricky, maybe someone else here knows a better way of doing it but here's how I would tackle the problem. Let's assume for simplicity that all views are loaded already. Let me know if this works
Setup an observer in the view controller that is being displayed by the tab selected in the tab bar controller. (Let's call this page TabPageVC). When the event that the TabPageVC is observing is fired have it segue way to page 3 immediately
In app delegate when the app becomes active / enters foreground check to see if you need to display page 3. If you do need to then get the root view controller in app delegate (i'm assuming it's the tab bar view controller, if it's not you'll need to set it to be).
Set the selected tab in the tab bar controller to be the tab of the index that TabPageVC lives in
Trigger that event that TabBarVC is observing this will cause TabBarVC to immediately segue way to page 3 and you'll have retained the stack
I have an app that has a toolbar, but I don't want the bar at the top, in order to free more viewing space. Therefore I have decided not to use a navigation controller. I'd like to add a back button to the toolbar. How would I go about this?
Adding the button is easy enough, and setting the action to performSegueWithIdentifier is all fine, but what happens is that the previous view just gets loaded again, rather than show it as it was, like a true back button. So if I tap on the 10th row on a tableView and go to a new page, when I press the back button it loads the view from the top again, instead of showing it as where I scrolled down to last.
Even though you don't want a UINavigationBar, you do want a UINavigationController in this case, because it manages the 'back stack' exactly the way you want it. Just hide its navigation bar by setting its navigationBarHidden property to true (in the Storyboard or in the viewDidLoad function of the root view controller).
You can then use navigationController.popViewController(true) as normal, in response to the user clicking your custom back button.
In iOS8, I have a root view controller where I would show another navigation view controller as the root vc's subview when user clicks on one button. I pre-loaded the navigation view controller in viewDidAppear to ensure responsiveness when user clicks on the button, since instantiating and adding subview would cause some latency.
However, if I put the setupNavigationVC() inside viewDidAppear(), my navigation bar would look like this when expanded to full screen.
if I let my code execute setupNavigationVC() right after user clicks the button, the navigation bar would look normal.
Also, I noticed that if I pause the app and then go back in. The navigation bar would return to normal. I suppose the OS must have reloaded every view when an app is resumed.
Thanks in advance!
I have a TabBarApplication with four views in the main TabBarItem. The problem comes when I go to any of these views and click in any button to go to another view and when I go back by a button linked to the main view, the TabBarItem of the app disappear!!
For example, one view of the app is a tableView in which each element of the list is linked to his external view and it has a back button that should return to the tableView. All the segues are by modal, not push because push segue crash the application and by modal it runs correctly but the problem comes when I returned by clicking the back button of the NavigationItem in the header of the view to his main view and the TabBarItem of the app is not there, is empty.
Each tab should have the view controller set to a navigation controller, with the view controller you want set as the root view controller of the navigation controller. Now you can use push segues and the standard back button that will be added for you. This will bypass the issue (and work much better for you and users).
You current issue is likely related to not really ever going back. Instead, just always presenting new modal view controllers which replace any existing content on screen.