在我的MainViewController
中,我通过这个展示了另一个视图控制器:
MessageViewController *messageController = [[MessageViewController alloc]initWithNibName:nil bundle:nil];
[messageController setModalPresentationStyle:UIModalPresentationFullScreen];
[messageController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:messageController animated:YES completion:nil];
[messageController release];
这将正确显示视图控制器。但是,当我尝试返回呈现视图控制器(在这种情况下应该是 )时MainViewController
,此代码不起作用:
if ([self.presentingViewController isKindOfClass:[MainViewController class]])
[(MainViewController *)self.presentingViewController setCurrentViewTag:2];
[self dismissModalViewControllerAnimated:YES];
我删除了“if..”条件以强制它设置当前视图标签。发生错误,告诉我呈现的视图控制器似乎是UINavigationController
:
[UINavigationController setCurrentViewTag:]: unrecognized selector sent to instance 0x8352a50
谁能告诉我为什么会这样?这段代码以前可以工作,我不确定是什么改变使它停止正常工作。
编辑
这是更新的代码:
ReaderController *readerController = [[ReaderController alloc]initWithNibName:nil bundle:nil];
[readerController loadWhichViewToShow:2];
[self setDefinesPresentationContext:YES];
[readerController setModalPresentationStyle:UIModalPresentationFullScreen];
[readerController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:readerController animated:YES completion:nil];
[readerController release];