我創建使用iOS中5問題與模態視圖控制器和definesPresentationContext
new UIViewController container view controller methods故障的自定義容器視圖控制器是,即使我的容器控制器的孩子的UIViewController有definesPresentationContext = YES
,當它creates and presents another modal view controller,UIKit中設置容器(而不是孩子)作爲呈現控制器。
例如,在MyChildViewController.m:
- (void)showMailComposeView:(id)sender {
__block MFMailComposeViewController *vc =
[[MFMailComposeViewController alloc] init];
vc.mailComposeDelegate = self;
vc.subject = @"Subject";
self.definesPresentationContext = YES;
[self presentViewController:vc animated:YES completion:^{
if ([self.modalViewController isEqual:vc])
NSLog(@"This should print...");
if ([vc.presentingViewController isEqual:self.parentViewController])
NSLog(@"... but this shouldn't");
// NOTE: Both log statements printed
}];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error
{
[self dismissViewControllerAnimated:YES completion:^{}];
// NOTE: self.parentViewController.view now displays instead of self.view
}
我要去哪裏錯了?
我如何確保它是孩子視圖,當模態視圖被取消(而不是容器視圖)時顯示?
雖然我的問題有點不同,但這個爲我工作!謝謝! – chadbag
同樣在這裏。這次真是萬分感謝! – Robert
有趣的是,爲什麼在iPhone上,模態總是從根視角出發。我在iPhone上有類似的容器情況,並做了以上所有的工作,我想知道爲什麼模態視圖沒有從子視圖控制器的視圖範圍內呈現出來。聽起來這只是一種與iPad不同的iPhone行爲。 – idStar