当在我的 UIToolBar 上单击完成按钮时,我想调出“TableViewController”的 .nib。但是下面的内容不允许单击以显示新视图。我该如何纠正这个问题?请告诉我哪里出了问题,应该更换什么以及为什么。
//Here's the selector in my overlay.
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:
UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed)];
//Here's how I made my action. Btw, the uitoolbar has no nib, it's an overlay on the
//(camera mode).
-(void)doneButtonPressed {
TableViewController *tableView = [[TableViewController alloc]
initWithNibName:@"TableViewController" bundle:nil];
tableView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:tableView animated:YES];
}
//Yet nothing happens when I click on my done button on my overlay. And I've made sure
// i've imported .h frameworks correctly too.
假设您要从 UItoolbar 叠加层上的 barbuttonitem 中调出一个 nib。你会怎么做?
有人告诉我,要使其正常运行,我必须添加 [barButtonItem addTarget:self action:@selector(doneButtonPressed) forControlEvents:UIControlEventTouchUpInside]; .
但是,如果我添加它,我会得到:
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:
UIBarButtonSystemItemDone addTarget:self action:@selector(doneButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
这导致我在读取“实例方法”时出现错误 - initWithBarButtonSystemItem:target:action:forControlEvents:' not found (return type defaults to 'id')
除了我在这里编写的代码之外,请向我展示解决方案,而不是只向我展示正确的添加剂。