是否可以删除iOS主 - 详细视图上的"编辑"和"+"按钮?

And*_*ula 3 iphone xcode ipad ios ios6

目前,我的iOS(6)应用程序使用Master-Detail视图模板,其中一些列表元素已预先填充.用户当前可以选择"编辑"并添加到('+')列表.有没有办法删除这些按钮,以防止原始列表被更改?

Rya*_*los 11

是的,有一个简单的方法.

查找这个代码MasterViewController.m,并删除这些行self.navigationItem.leftBarButtonItem = self.editButtonItem;,self.navigationItem.rightBarButtonItem = addButton;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.navigationItem.leftBarButtonItem = self.editButtonItem;

    UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)];
    self.navigationItem.rightBarButtonItem = addButton;
}
Run Code Online (Sandbox Code Playgroud)