How to set the Navigationitem of Uinavigationcontroller

Source: Internet
Author: User

Method 1

Self. Navigationitem. Rightbarbuttonitem = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem: Uibarbuttonsystemitemedit target:self action:@selector(edit)];

< Span class= "S3" > where the Edit method in @selector is the Listen method for the Edit button

< Span class= "S3" >/*

< Span class= "S3" >* Custom listener Events

< Span class= "S3" >*/

< Span class= "S3" >-(voin) edit

< Span class= "S3" >{

< Span class= "S3" >}

Method 2

Self. Navigationitem. Rightbarbuttonitem = self. Editbuttonitem;

The edit button defined by the method has the system's own listening method

/*

* Listen for the Edit event (this method is a method in Uiviewcontroller, so other Uiviewcontroller subclasses can also be called, and can be nested calls )

*/

If the class has attributes @property (nonatomic,retain) UITableView *mytableview;

The

-(void) setediting: (bool) editing animated: (bool) animated

{

[Super setediting: Editing animated: animated]; When the method is called, the method of the parent class must be called First

NSLog(@ " edit state:%@", editing? ) @ "Yes":@ "no");

[_mytableview setediting: Editing animated: animated];

}

Method 3

UIButton *leftbtn = [[UIButton alloc] initwithframe:cgrectmake(0, 0, 40, )];

[Leftbtn settitle:@ " edit " forstate:uicontrolstatenormal];

[Leftbtn settitlecolor: [uicolor blackcolor] forstate: UIControlStateNormal];

[Leftbtn addTarget:self action:@selector(edit) forcontrolevents: UIControlEventTouchUpInside];

uibarbuttonitem *leftitem = [[uibarbuttonitem alloc] initwithcustomview: LEFTBTN];

self. Navigationitem. Leftbarbuttonitem = leftitem;

How to set the Navigationitem of Uinavigationcontroller

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.