@techytube
  @techytube
techytube | How to create view controllers programmatically in iOS @techytube | Uploaded 11 years ago | Updated 1 minute ago
Subscribe to our channel here for notifications on new video trainings. For more videos on technology, visit our website at http://www.techytube.com.
By pavel@techytube, for more from this author visit:
http://www.techytube.com/author/pavel

The UINavigationController class implements a specialized view controller that manages the navigation of hierarchical content. This class is not intended for subclassing. Instead, you use instances of it as-is in situations where you want your application's user interface to reflect the hierarchical nature of your content. This navigation interface makes it possible to present your data efficiently and also makes it easier for the user to navigate that content.
To create a navigation controller programmatically, you have to write the following code:
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
Usually that is done in the "AppDelegate.m" file, but it can be done in any file you need.
If you do that in the "AppDelegate.m" file than you should replace the line:
self.window.rootViewController = self.viewController;
with the following line:
self.window.rootViewController = navController;
and it is perfectly ok because UINavigationController is a subclass of UIViewController.
If you run the program, you may notice a blue navigation bar appears on the top. You can customise that if you want, or you can hide it using any of the 2 lines below:
navController.navigationBarHidden = YES;
navController.navigationBar.hidden = YES;
To set a title in the NavBar, you should write in the "viewDidLoad" method of the ViewController class that is currently displayed by the Navigator object, any of the 2 lines below:
self.navigationItem.title = @"Title";
self.title = @"Title";
How to create view controllers programmatically in iOSSonicWall - How to allow or block access to a specific websiteDifferent types of UITableView cells in iOSLinux Archive, Backup And Compress Utility (tar, Gzip, Bzip2, 7zip, Zip etc.) Part - 2

How to create view controllers programmatically in iOS @techytube

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER