我有PreviewController
:UIViewController
用于全屏显示文档,它是UINavigationViewController
. 也是 的代表UISplitViewController
。
当它被推动时,它会隐藏masterView
起来UISplitViewController
。(方法 1 - 3 - 2 被调用)
当它消失时(通过按“返回”按钮),它显示masterView
. UISplitViewController
(调用方法 4 - 2)
但是有一种方法可以强制关闭PreviewController
。在这种情况下,只有方法 4 被调用并被PreviewController
释放,然后UISplitViewController
才能发送消息并调用方法 2。
我该如何解决这个问题?有没有办法强制UISplitViewController
调用它的委托方法?或者我可以PreviewController
在方法 4 中保留并在方法 2 中释放它(使用 ARC)?
// Method 1
- (void)viewDidLoad
{
[super viewDidLoad];
self.hideMaster = YES;
UISplitViewController *splitViewController = [(AppDelegate *)[[UIApplication sharedApplication] delegate] splitViewController];
splitViewController.delegate = self;
}
// Method 2
- (BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
{
return self.hideMaster;
}
// Method 3
- (void)viewWillAppear:(BOOL)animated
{
self.hideMaster = YES;
UISplitViewController *splitViewController = [(AppDelegate *)[[UIApplication sharedApplication] delegate] splitViewController];
[splitViewController.view setNeedsLayout];
[splitViewController willRotateToInterfaceOrientation:self.interfaceOrientation duration:0];
}
// Method 4
- (void)viewWillDisappear:(BOOL)animated
{
self.hideMaster = NO;
UISplitViewController *splitViewController = [(AppDelegate *)[[UIApplication sharedApplication] delegate] splitViewController];
[splitViewController.view setNeedsLayout];
[splitViewController willRotateToInterfaceOrientation:self.interfaceOrientation duration:0];
}
// PreviewController is created in UIViewController which belongs to UINavigationController
PreviewController *previewVC = [[PreviewController alloc] initWithNibName:@"PreviewController" bundle:nil];
previewVC.documentURL = url;
[self.navigationController pushViewController:previewVC animated:YES]