iOS - NavigationBar Title overlapped by previous viewController - ios

we have the issue, that if we pop back from a VC, the current ViewController's navigationBar title is overlapped by the just popped VC navBar title.
But it occurs only sometimes, so i assume it's maybe just a UI refresh bug. Did someone have this problem before, if yes.., how to fix it?
regards ..

I've run into this a few times in the app I maintain. In every case the problem was caused by people doing silly things with navigation controllers.
For example, when wishing to navigate to a new view, a view controller that was already part of a navigation controller's view stack would instantiate a new navigation controller and push its root view controller onto the first navigation controller's view stack.
Then, in the new view controller (the one contained in the second nav controller's view stack), they would try to pop to a previous view. This would cause funny animation bugs and random titles to show on the navigation bar.
The solution was to remove the second navigation controller from the flow (it didn't serve any particular purpose).

Related

Back Navigation from Embedded UISplitViewController Using Single Navigation Bar

I’d like to have split views in several places of my iOS app, none of them as the root view controller. I understand that split views are initially designed to sit at the root of the app and provide the root navigation controller, and that Apple’s guidelines initially did not allow any workarounds. Updated guidelines state
You cannot push a split view controller onto a navigation stack. Although it is possible to install a split view controller as a child in some other container view controllers, doing is not recommended in most cases.
Now the split view pattern would really benefit my app, and I don’t want to reinvent the wheel here, so I gave it a try using a container view, mainly using the following steps:
Create a scene with a regular UIViewController.
Add a UIContainerView covering the entire screen.
Add a UISplitViewController to the storyboard, which creates a split view controller, a navigation controller, a table view controller (for the master view), and a regular view controller (for the detail view).
Create an embed segue from the container view to the split view controller.
This has a few quirks, which I hope to iron out eventually (e.g. initially showing detail view, swiping in the table view from the left on an iPad apparently tries to also back nav on the main navigation), but it basically works. So far, so good.
Now, the problem is that I have two navigation controllers: the main navigation controller at the root of my app and the navigation controller in the embedded split view. This gives me two navigation bars with independent navigation, allowing me to:
navigate back to the root of the split view using the embedded navigation controller
navigate back from the container view in the enclosing navigation controller
Besides two navigation bars not being appealing, I don’t want iPhone users to perform the second directly from the detail view. So my next steps were:
hide the navigation bar in the outer view controller
add a back navigation button to the inner navigation bar to take over the role of the main navigation bar’s back button
Left to do is the implementation for that back button that pops the container's view controller of the main navigation stack. The question is: how can I access the main navigation controller from the embedded view that has its own navigation controller (using Swift)?
Accessing the navigation stack of the parent's (containing view controller's) navigation controller turned out to be straightforward:
#IBAction func backButtonTapped(_ sender: UIBarButtonItem) {
parent?.navigationController?.popViewController(animated: true)
}
I had to face a similar kind of problem while developing my app.
My problem was, I had to display navigation controller and splitviewcontroller on side bar. Again a problem was navigation controller form splitview to navigation controller. Below are the steps which i followed
1) While creating a split view controller, I hided the navigation controller of master and detail and set it to root view, please also keep the reference of your top level navigation controller.
2) I increased the 'y' of splitview.root.window and view to accommodate custom view.
3) I created a custom view with a back button and then handled the transition with animation.
Please let me know if you want code snippets. I would have shared it now. But i have to search for it.

Toolbar not visible

Can anyone tell me why, in the storyboard here below, when I arrive from the first tab the toolbar is visible, but when I arrive from the second tab is not visible anymore.
The first tab has a navigation controller as the root controller - the second does not.
You can select SearchVC in your storyboard and then use the Editor - Embed In - Navigation Controller menu option to add a navigation controller. That might not be how you want your UI. But that would achieve what you want visually ...
Update:
Based on discussions with the OP, the issue was that SearchVC was adding EditorVC as a child view controller and then EditorVC in turn would add ReadVC to the navigation stack.
EditorVC, as it appears above, is embedded within a UINavigationController. I suggested that OP remove that UINavigationController instance and then push EditorVC on to SearchVC's navigation controller and then later when ReadVC is displayed from EditorVC, again push ReadVC on to the existing navigation controller. I believe this should resolve the issues that OP was seeing.

How to "virtually" tap back button in Navigation Bar

I have app, where is Segmented Control inside of my Navigation Bar. Under navigation bar I have 3 containers. In these containers I have Table View Controllers. If you tap on segmented control, one TVC appear and others disappear (container1.hidden = true and so on).
Problem is when I press "save" button which is also in navigation controller - button doesn't trigger "virtual push of back button".
I used following code which works in my other projects (its in button's action which is in VC that contains all container views) but not this time:
if let navController = self.navigationController {
navController.popViewControllerAnimated(true)
}
Image for better insight:
UPDATE: Thanks to # Alexey Bondarchuk I solved it. Comments may be confusing so I just recap problem and solution.
Originally, I had ViewController. To this controller I embed in Navigation Controller. To this Navigation Controller I connected segues. And that was mistake.
So I deleted this embed in navigation controller, made (show) segues directly to my View Controller (which is on screenshot). This automatically created navigation bar and last thing I did was that I put navigation item in it so now my code pop right navigationController. Hope that it's understandable.
I have couple ideas:
Your navigationController equal to 'nil' and .popViewControllerAnimated will never invoked. This may happen if you are using UITabBarController. In this case try to use self.tabBarController?.navigationController instead of self.navigationController.
Your controller presented 'Modally'. In this case you can try to invoke navController.dismissViewControllerAnimatedinstead of navController.popViewControllerAnimated

The TabBarItem disappear when I push in other view

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.

Issue with tab and navigation view controller

I have an iOS app which is structured in this way:
One tab bar controller with 4 navigation controllers. Each navigation controller has its own view controller with a xib file.
The issue, is that ONLY THE FIRST TIME, when I push a new view into one of the navigation controllers, the new view doesn't appear at all. When I switch to another nav controller (touching one of tab bar's options) and then switch back to the first one, it works all the time.
The error I'm getting is when I come back is:
[35731:70b] Unbalanced calls to begin/end appearance transitions for
.
Thanks for helping out.
Make sure you are presenting all your view controllers from the parent / top level view controller (the tab bar controller). I've had this a few times when presenting a view controller from one of the view controllers in the tab bar.
In viewdidload assign your first view controller to load when xib loads. Its the correct way to load first view controller to appear when nib loads.

Resources