When using popToRootViewController I lose my navigation bar - iphone

I have an iOS app where the main screen is a UICollectionViewController. When selecting an Item from the collection view the view is pushed to a detail view of the item. In the detail view I built a drawer/slider that moves out from the side. In order to get the view to look the way I wanted I hid the default navigation bar and inserted one via storyboards.
I ran into an issue that when hiding the default navigation bar you lose the back button functionality that comes with using a navigation controller. I worked around this by adding a button where the back button would have been (the image above is shown without the button). Now I use the line of code below to move back to the collection view.
[self.navigationController popToRootViewControllerAnimated:YES];
It works the way I want it except that I lose my Navigation Bar when I return to the collection view. Does anyone have any thoughts on how to fix this? Thanks in advance!

In viewWillAppear of your rootViewControler
-(void)viewWillAppear:(BOOL)animated{
[self.navigationController setNavigationBarHidden:NO];
}

I know this thread it's a little dated (more than dated more like an archive). But I ran into the same issue in swift 5, Xcode 13. Below is the swift code that I used in my viewWillAppear in case it helps someone.
self.navigationController?.setNavigationBarHidden(false , animated: true)

Related

Making a UITabView show the second level of a navigation controller by default

(Apologies for not being able to embed my images yet).
Using iOS storyboards, I have a UITabBarController with a UINavigation Controller/UITableView(1) embedded in it. This UITableView(1) then calls another UITableView(2):
What I'm trying to do is to make UITableView(2) appear when the Tab Bar is changed to that tab, and then have the UINavigationBar left arrow button exist to get back to UITableView(1).
The existing functionality I can think of which does this is the iPhone Mail app, where when you launch it you see your Inbox, and you can hit the left-arrow Mailboxes button to get back to your mail box list.
I've tried attaching the tab bar directly to UITableView(2) but it doesn't work as expected, there's no left arrow back button to get back to the previous view when the app is run.
I've also tried adding a navigation controller to that UITableView(2) and the Navigation controller correctly appears, but still without any back button:
Any suggestions as to what I'm doing wrong would be greatly appreciated, I'm fairly new with storyboards and it's difficult to find what to search to get this working.
If it's not possible with just storyboards themselves, is there some kind of automatic (non-visible) push to the 2nd UITableView I could do?
Thanks!
Nick.
This tutorial will definitely help you : http://maybelost.com/2011/10/tutorial-storyboard-in-xcode-4-2-with-navigation-controller-and-tabbar-controller-part1/
I ended up implementing it the following way, as I wanted to perform the majority of the work within storyboards.
I set up the storyboard with the tab bar embedding the UINavigationController, which contained UITableView(1) which then contained a custom segue to UITableView(2):
Then within the class associated with UITableView(1) I added this single line:
- (void)viewDidLoad {
[self performSegueWithIdentifier:#"campaigns" sender:self];
...
}
On load of the tab, the viewDidLoad of UITableView(1) instantly calls UITableView(2) without any kind of animation, showing the back button to UITableView(1), which is exactly what I wanted.
Thanks to those who responded!
You can implement the delegate method as below.
(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
In this method you can check for the tabBarController.selectedIndex or viewController object. This ensures the selection of correct tab , then push the controller having table 1, then push the controller having table 2.

What to do about "Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted."

I'm writing an iPhone app using Appcelerator Titanium Mobile. I am hiding and showing the tab group based on what window has focus.
dashWin.addEventListener("focus",function(e) {
if (dashWin.tabGroupVisible == true) {
dashWin.tabGroupVisible=false;
tabGroup.animate({bottom:-50,duration:500});
}
});
The code above hides the tab group when dashWin receives a focus event. However, I see this message in the Titanium console when the event fires while running in the iPhone simulator:
Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
A Google search turns up one result: Another StackOverflow question that may have a hint as to what's going on.
I got this error when I linked Action Segue or Selection Segue from one view to another view through storyboard and performed the same segue programmatically again, which makes the navigation controller perform the same segue twice.
2 solutions for this case:
Removing the code that pushes the view. Just let storyboard perform the segue for you. This is good for most situations.
Replacing Action Segue or Selection Segue with Manual Section and do - (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender by yourself. You may find this solution useful when you want to customize the behavior of segue according to the sender.
Usually a tab group acts as the root of your app's navigation. When a user taps a tab, that tab's window is focused.
Next, when a user triggers an action that requires a new window appear, it usually appears either modally or on top (in the navigation stack sense) of the current window. In the latter case, tell the current tab to open the new window.
If you set the tabBarHidden property to false (when you create the new window), the tab bar will be hidden for you when the new window is opened by the current tab.
Will this more standard approach work for you?
I had segues that were leading back to my main navigation controller which was causing this. I fixed the problem by setting the main navigation controller back to the top of the stack. Here is the code:
- (void) viewDidAppear:(BOOL)animated
{
[self.navigationController popToRootViewControllerAnimated:NO];
}
Recently, I've faced the same problem. The reason was:
-I was trying to pop view controller twice by mistake.
you can check this crash by setting breakpoints on push and pop View controllers

Current UIView Questions iPhone SDK

I posted earlier but am running into similar problems again. Basically the way that my app is setup there is a top bar that is basically just a static image that has UIButtons placed on top of it. That is the Main View Controller and is persistent no matter what view is shown beneath it. I can't use a navigation controller because it is not possible to change the height and I need the bar to be significantly larger than a navbar. However my bar is functioning in much the same way. There is a "Home" Button, a "Back" Button and several destination buttons.
I understand how to switch views from say the home screen. My confusion comes with the back button. In order to press back the app is going to need to know what view is currently being displayed so that it can be removed from view and a new subview can be added. Ideally I would use the UINavigationController so that I can push and pop views which is really what I want to do here, however that is not possible because of the visual problem.
Does anybody know of a method that returns the current displayed view so I could do something like the following
[currentview.view removeFromSuperView];
[self.view insertSubview:experienceViewController.view atIndex:0]
You can use UINavigationController with the nav bar hidden. Put the nav controller inside a view that does have your jumbo toolbar and you'll have access to the push/pop behavior you're looking for.

UISearchDisplayController,UINavigationController,UITabBarController Woes

Hey everyone, running into a bit of an issue,
I have created all my views through IB, with the main window having a NavigationController, and a TabBarController which loads a TableViewController in its first tab.
The problem happens when i use the searchbarcontroller in the navigation controller, everything works fine with the exception that when the navigation bar at the top disappears, the table expands too high, and i can't figure out what im doing wrong.
Attached is an image of what im referring to, any help would be greatly appreciated.
alt text http://img263.imageshack.us/img263/4706/picture1ot.png
Some more information:
i have my MainWindow with a UINavigationController, and a UITabBarController. On the first Tab, i have it loading another nib "AVN_TableController" which is a UITableViewController nib, with the Searchbar delegate.
If you've set your view sizes correctly in Interface Builder and are using the "Simulated Interface Elements" to cause the status bar, navigation bar, and tab bar to display, it should work correctly. If not, then what comes to mind is this issue where displaying an action sheet has it's tappable rectangle offset by the height of the tab bar because it is added to the wrong view. Not sure if that would apply here, but it's at least something to consider.
I ended up going the route of creating my own tabbarcontroller, as that was causing the issue.

How to go to Previous View? - iPhone Devlopment

I am Using a Navigation based application.
However i don't want to push a view.
I have changed present ModalViewController.
Now, I am confused - how to load previouse view.
My Application's Table View - default in navigation base application
On navigation controller I have added (add employee) button.
On Add(employee) click i have written following code in appDelegate.m
-(IBAction)AddClicked:(id)sender
{
if(self.addData==nil) // addData is a object of my next view
{
addData=[[AddEmpScrn alloc] initWithNibName:#"AddEmpScrn" bundle:nil] autorelease];
}
[self.navigationController presentModalViewController:self.addData animated:YES];
}
This code works successfully & next Add Employee screen load perfactly.
But Now I am confused.
How to get back to previous view?
that is if a user click on "Save" or "Cancel"
it should display again the previous view...
main screen
I dont know how to solve it...
anybody please help me...
i will be thank full.
Have u tried using the dismissModalViewController method? should do what you are asking f or
Have you read "Using Modal View Controllers"?
If you presentModalViewController then the old view is still there "behind" it. You just need to call dismissModalViewControllerAnimated: on the original navigation controller.
If you are directly manipulating the view hierarchy by swapping out subviews, you will need to hold onto the old view in another member variable and make sure to retain it.