【发布时间】:2012-10-30 12:11:49
【问题描述】:
我在 iphone 应用程序中有两个视图控制器。
1.) 第一VC
2.) 第二个VC
在我的 FirstVC 中,我有一个按钮。通过点击该按钮,我在presentModalViewController 中打开了 SecondVC。看下面的代码。
- (IBAction)buttonClicked:(id)sender
{
SecondVC *secondVC = [SecondVC alloc] initWithNibName:@"SecondVC" bundle:nil];
[self.navigationController presentModalViewController:secondVC animated:YES];
}
现在移至 SecondVC。在 SecondVC 上,我创建了导航栏以及“取消”按钮作为 leftBarButtonItem。我在取消按钮上设置了一个按钮单击事件。在那种方法中,我想解雇 SecondVC。波纹管方法在 SecondVC 中。看下面的代码。
- (void)cancelButtonClicked
{
[self dismissModalViewControllerAnimated:YES];
}
此代码不起作用。我不能通过这段代码解雇 SecondVC。请提出其他技巧。
【问题讨论】:
-
当你尝试显示 secondVC 视图时,只需删除 navigationController...试试
-
@ParasJoshi:我也试过了。但没有运气。
-
首先确认您没有在某个线程运行时关闭它。
-
@ForamMukundShah:没有。没有线程在运行。
-
好的。虽然我建议你写 '[self performSelectorOnMainThread:@selector(cancelButtonClicked) withObject:nil waitUntilDone:YES]; '
标签: iphone uiviewcontroller presentmodalviewcontroller