iOS Development OC Navigation bar Uinavigationcontroller Toolbar Uitoolbar

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.