Reputation: 1251
i created a UICollectionviewcontroller
view and embed a UINavigationcontroller
then I created one button in navigation bar.Again i created one UITableviewcontroller
also i embed one uinavigationcontroller
to it,when i click the button in UICollectionview
navigation bar it shows the UITableviewcontroller
up to this point is fine,but after this the navigation bar in UITableview
controller is not showing at all.please help me
Upvotes: 1
Views: 5374
Reputation: 31
Further to the above answers, I have also struggled in a similar way with moving programatically between tabs of a UITabBArController.
Most posts I read suggested
tabBarController?.selectedIndex = 0
however this would create the situation where the tab bar was no longer visible. Eventually solved by adding the following to the class in AppDelegate.swift
var tabBarController: UITabBarController?
and then also in AppDelegate, I modified didFinishLaunchingWithOptions as follows:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
tabBarController = window?.rootViewController as! UITabBarController
return true
}
You can then use the following line anywhere inside your various view controllers
tabBarController?.selectedIndex = 0
Upvotes: 0
Reputation: 165
In addition to @barryjones solution, you can directly push a table view controller using the navigation controller.
[self.navigationController pushViewController:yourTableViewController animated:YES];
Upvotes: 0
Reputation: 31
I also struggled with this. Eventually solved by adding a Navigation Controller as defined in https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/WorkingwithConstraintsinInterfaceBuidler.html
Upvotes: 0
Reputation: 2309
According to apple docs, this won't be showing the navigation controller. In order to show the navigation controller you need to instantiate a navigation controller first, and then load the table view controller as shown below :
LTBaseTableViewController *viewController = [[LTBaseTableViewController alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[self.window setRootViewController:navigationController];
Upvotes: 2
Reputation: 483
Try this piece of code to set the navbar to not be hidden:
-(void) viewWillAppear:(BOOL)animated {
[[self navigationController] setNavigationBarHidden:NO animated:YES];
}
Good luck
Upvotes: 3