iPhone Storyboard Editing a table view

前端 未结 7 1465
囚心锁ツ
囚心锁ツ 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 05:10

    I just started using Storyboards, so I also wanted to use the Storyboard to add my Edit button. It is annoying to have taken the time to learn how to use a new tool but find you need a roll of duct tape to patch up the holes.

    You can get it to work, but need to add a Custom button. In the Attributes inspector make sure the Identifier is Custom and the title is Edit.

    Then add something like this in your .m

    - (IBAction)setEditMode:(UIBarButtonItem *)sender {
        if (self.editing) {
            sender.title = @"Edit";
            [super setEditing:NO animated:YES];
        } else {
            sender.title = @"Done";
            [super setEditing:YES animated:YES];
        } 
    }
    

    Have your Custom Edit button call the setEditMode method.

    Can only hope they will fix the implementation of the Edit button in the Storyboard editor in the future.

提交回复
热议问题