我有一个带有导航栏的导航应用程序,但有一些情况下,我需要以模态的方式呈现视图控制器,而不是将其推入堆栈。问题在于,当我解除模态视图控制器时,除了按照文档所预期的隐藏导航栏并调整(父视图)大小外,其他所有功能都正常运行。因此,我想我可以简单地调用一个内置方法来取消隐藏导航栏。我已经尝试过
[self.navigationController setNavigationBarHidden:NO];
尝试使用动画版也没有成功。
文档在该方法中有所涉及。
presentModalViewController: animated:
在讨论部分中,有这样的话:
在iPhone和iPod touch设备上,模态视图控制器(modalViewController)的视图总是以全屏方式呈现"并且“将modalViewController属性设置为指定的视图控制器。调整其视图大小并将其附加到视图层次结构中。”但是,文档并没有提示我如何在关闭模态视图后撤消此过程。
还有其他人遇到过这个问题并找到了解决方案吗?
编辑:我也遇到了同样的问题,所以我赞助了这个问题的悬赏。这是我的具体情况:
在我的情况下,我正在一个导航控制器上展示一个图像选择器(Image Picker),它是在一个模态视图控制器中呈现的:
-(void) chooseImage {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
imagepicker = [[UIImagePickerController alloc] init];
imagepicker.allowsEditing = NO;
imagepicker.delegate = self;
imagepicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagepicker.navigationBar.opaque = true;
imagepicker.wantsFullScreenLayout = NO;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
if (self.view.window != nil) {
popoverController = [[UIPopoverController alloc] initWithContentViewController:imagepicker];
[popoverController presentPopoverFromBarButtonItem:reset permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
} else {}
} else {
[self.navigationController presentModalViewController:imagepicker animated:YES];
}
}
}
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[self.popoverController dismissPopoverAnimated:true];
} else {
[self.navigationController dismissModalViewControllerAnimated:YES];
}
//Save the image
}
-(void) imagePickerControllerDidCancel:(UIImagePickerController *)picker {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[self.popoverController dismissPopoverAnimated:true];
} else {
[self.navigationController dismissModalViewControllerAnimated:YES];
}
}