简体   繁体   中英

editing the UItableview using barbutton item

i am trying to edit the UItableview . what i am doing is trying to diplay a leftbarButton on my navigation bar

i wrote this code in my viewdidload

[self.navigationItem setLeftBarButtonItem:self.editButtonItem];

but its not showing any button on my navigation bar :S

PS : My currentview is subview of tabbarcontroller and i am using UItableView and UInavigationbar in my interfacebuilder .

can any one help me

thanks in advance

regards

Edit : I am not using UItableViewController

i cant get this work if i dont use UItableViewController .

Where have you placed the above code in? It should be in the viewDidLoad of the tableView implementation file

Ideally, init the navigation controller with your tableview controller. Then place the above code you've written inside the viewDidLoad of the tableViewController. It should work normally as expected.

UITabBarController and UINavigationController work as container, they can contain other UIViewController's instances inside. So, you can use UITabBarController to contain sub view which are UITableViewController's subclasses.

You can read the sample codes of TheElements and LocateMe . They use UITabBarController to manage other UIViewController instances. Like TheElements , it manages UITableViewController instances by UITabBarController.

And then, you can display the edit button of UITableViewController.

Or, you can use the method of UITableView to enter the editing mode or leave the editing mode.

- (void)setEditing:(BOOL)editing animated:(BOOL)animate;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM