The most common example of a navigation bar is where the button is returned.
In APPDELEGATE.M, when the code layout is first defined in the window, _window.rootviewcontroller should be a Uinavigationcontroller
Here's the uinavigationcontroller, poke in the definition to find out it's a uiviewcontroller subclass
The Rootcontroller used here in the previous code layout is Uiviewcontroller
So it also contains multiple controllers in the same way as the Uiviewcontroller in the previous code layout, so as Rootcontroller
According to my own understanding, Uinavigationcontroller is a special Uiviewcontroller with navigation bar, we use the navigation bar, we choose to use it
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions { // Override point for customization after application launch.
*rootnav = [[Uinavigationcontroller alloc] Initwithrootviewcontroller:[[viewcontroller Alloc]init]]; = [[UIWindow alloc]initwithframe:[uiscreen mainscreen].bounds]; = Rootnav; [_window makekeyandvisible]; return YES;}
The navigation bar is temporarily completed, the following defines the toolbar
Create a new view, the parent chooses Uitoolbar, and this is our own toolbar view
Toolbar as a standalone view, and the previous code layout in our own mainview is no different, the way to add controls is the same
But this toolbar is just a toolbar, so positioning is positioned only in a small area of the toolbar, which is almost the only difference
Now, we're going to load a view that we want for ourselves, add a navigation bar by changing the Rootcontroller type, and now we're going to add the navigation bars, more than one view to load
In the last simple code layout, the Loadview that was overridden in VIEWCONTROLLER.M
-(void) loadview { = [[MainView Alloc]initwithframe:[uiscreen mainscreen].bounds];}
The definition of the root view directly assigned to our own Mainview this one, now we need more than one, you can
-(void) loadview{ [self.navigationitem settitle:@ " memo "]; [Super Loadview]; [Self.view Addsubview:[[notelistview alloc] initwithframe:[uiscreen mainscreen].bounds style: Uitableviewstyleplain]]; [Self.view Addsubview:[[notelisttoolbar alloc] initwithframe:cgrectmake (0 ]];
First call the parent class of the Loadview, [Super Loadview], to ensure that we have a basic view exists, although he is empty, expressed as a black screen
You can then use Addsubview in this view to add the view you want
In addition, the self here is the first Rootcontroller type Uinavigationcontroller, using its properties to define the title
iOS Development OC Navigation bar Uinavigationcontroller Toolbar Uitoolbar