Avi*_*ron 4 iphone objective-c uiviewcontroller ipad ios
我为PopoverController创建了自己的类(没有子类化UIPopoverController)以我想要的方式呈现ViewControllers.
CustomPopoverController不是UIViewController,而是有一个名为"contentViewController"的ivar,它实际上是显示的VC.
当用户点击contentViewController框架之外的任何地方时,我实现了自己的"dismissPopoverAnimated:"以解除我的自定义弹出窗口:
-(void) dismissPopoverAnimated : (BOOL) animated
{
// dismissalView is the view that intercept the taps outside.
[self.dismissalView removeFromSuperview];
self.dismissalView = nil;
if (animated)
{
CGRect newFrame = self.view.frame;
// When in landscape Mode the width of the screen is actually the "height"
newFrame.origin.y = [UIScreen mainScreen].bounds.size.width;
[UIView animateWithDuration:0.5
animations:^{self.view.frame = newFrame;}
completion: ^(BOOL finished) {if(finished) [self.contentViewController.view removeFromSuperview];}];
}
else
{
[self.contentViewController.view removeFromSuperview];
}
isPresented = NO;
[self.delegate customPopoverDidDismissPopover:self];
}
Run Code Online (Sandbox Code Playgroud)
问题是,即使removeFromSuperView
在任何情况下被调用 - 动画与否,contentViewController
永远不会接收viewWillDisappear
,viewDidDisappear
或者即使viewDidUnload
我正在发布contentViewController
;
有谁知道为什么?或者甚至更好地在viewWill .../viewDid ...方法链上抛出一些亮点,以及它们应该被调用的时间.
Aec*_*Liu 10
当您添加子视图或通过UIView的方法删除子视图,它不会导致国有UIViewController
呼叫viewWillAppear
,viewDidAppear
,viewWillDisappear
,和viewDidDisapper
.只有那些通过的viewController的方法管理UINavigationController
,如pushViewController:animated:
或popViewControllerAnimated:
,或presentModelViewController:aniamted:
......等,他们将通知有关情况正在改变控制器的看法.