从barbuttonitem切换视图?

时间:2012-07-30 00:15:06

标签: ios uitoolbar

所以我之前看到的问题类似于此,但它们没有任何帮助。我也读过Apple的文档,但我无法理解我哪里出错了。 AFAIK我在逻辑上做了所有事情,但是当我点击UItoolbar叠加上的完成按钮时,按钮可以被按下但是它什么也没做。这显然意味着它无法确认书面代码。但是如何?

当我在UIToolBar上单击完成按钮时,我想调出“TableViewController”的.nib。但下面不允许点击显示新视图。我该如何纠正这个?请告诉我哪里出错了,应该更换什么以及为什么。

//Here's the selector:
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:
UIBarButtonSystemItemDone target:self  action:@selector(doneButtonPressed)];

以下是我采取行动的方式。顺便说一句,uitoolbar没有笔尖,它是imagepickercontroller(相机模式)的叠加。

-(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. The button can be
clicked nothing happens. Please shed any insight pleasee!

1 个答案:

答案 0 :(得分:0)

这实际上可能不是问题所在,但如果你上面使用的代码是你解雇你的Modal视图控制器的方式,则它是不正确的。除了可能的不当使用,我没有看到任何问题。

使用您用来呈现Modal视图控制器的内容,然后使用它来解除它:

[self dismissModalViewControllerAnimated:YES];