I have .xib(not .storyboard) file in which I have an UIView which also has an UITableView inside of it. So, now I want to add navigation feature, but I can not embed a navigationcontroller
like in this tutorial http://www.appcoda.com/use-storyboards-to-build-navigation-controller-and-table-view/ because I use .xib not a .storyboard.
How can I add navigation feature to my app?
You can add it programmatically instead.
For example:
// Swift
let navController = UINavigationController(rootViewController: Your View Controller)
// Obj-C
UINavigationController *navControler = [[UINavigationController alloc] initWithRootViewController: YourViewController];
Then either push/present the navigation controller depending on when you're planning on showing it.
Having looked at the tutorial, I'm assuming you're going to be showing the navigation controller as the first screen, in which case you can add it to the AppDelegate
like this.
// Swift
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window?.makeKeyAndVisible()
self.window?.rootViewController = navController
// Obj-C
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window makeKeyAndVisible];
[self.window setRootViewController: navController];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With