我遇到了一个问题:我在我的 UiNavigation 控制器中以编程方式创建了一个 UIBarButton。但是,我希望它在按下时发出警报。但是,当我使用带有自定义文本的自定义栏按钮时,它不起作用:
self.navigationItem.rightBarButtonItem = self.editButtonItem;
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:@"Subscribe" style:UIBarButtonItemStyleDone target:nil action:@selector(subscribe:)];
self.navigationItem.rightBarButtonItem = addButton;
但是当我做一个普通的条形按钮时,它工作正常:
self.navigationItem.rightBarButtonItem = self.editButtonItem;
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(subscribe:)];
self.navigationItem.rightBarButtonItem = addButton;
这里是空白:
-(void)subscribe:(id)sender {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Highscore" message:@"" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];
[alert show];
}
提前致谢, 拉菲