我有一个右栏按钮的导航栏:
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonItemStyleDone target:self action:@selector(done)];
虽然当我将应用程序编译到设备上时,按钮会在其上进行编辑,而不是像应该的那样完成。这是为什么
我按下这样添加按钮:
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonItemStyleDone target:self action:@selector(done)];
这是视图的整个代码:
-(void) done {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Edit";
self.view.backgroundColor = [UIColor whiteColor];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonItemStyleDone target:self action:@selector(done)];
// Do any additional setup after loading the view.
}
我没有使用xib文件只是纯粹的代码,而是从另一个
呈现给控制器答案 0 :(得分:1)
你的问题是你正在使用完成按钮的样式,这意味着它会说编辑而不是完成,因为它基本上是一个编辑按钮,它不响应某些选择器编辑按钮。要解决此问题,请将代码更改为:
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonItemStyleDone target:self action:@selector(done)];