iPhone Storyboard Editing a table view

前端 未结 7 1375
囚心锁ツ
囚心锁ツ 2021-02-06 04:15

I\'ve been trying to learn the new Storyboard feature in Xcode and I\'ve run into a problem with trying to set a UITableView to edit mode.

So far my storyboard looks lik

7条回答
  •  梦谈多话
    2021-02-06 04:54

    In case that you have UIViewController and inside this you added a UITableVIew. If you want to add an edit UIBarButton in order to interact with UITableView, try:

    Add this line...

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        ...
    
        self.navigationItem.leftBarButtonItem = self.editButtonItem;
    
        ...
    }
    

    and this method

    - (void)setEditing:(BOOL)editing animated:(BOOL)animated {
    
        [super setEditing:editing animated:animated];
        [self.myListTableView setEditing:editing animated:animated];
    
        if(self.myListTableView.editing) {
            NSLog(@"editMode on");
        } else {
            NSLog(@"editMode off");
        }
    }
    

    where

    @property (weak, nonatomic) IBOutlet UITableView *myListTableView;
    

提交回复
热议问题