【发布时间】:2011-08-19 04:05:45
【问题描述】:
我为 PopoverController 创建了自己的类(没有子类化 UIPopoverController)以我想要的方式呈现 ViewController。
CustomPopoverController 不是 UIViewController,而是有一个名为“contentViewController”的 ivar,它是实际显示的 VC。
我实现了我自己的“dismissPopoverAnimated:”来在用户点击 contentViewController 框架之外的任何地方时关闭我的自定义弹出框:
-(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];
}
问题是,即使在任何情况下都调用了removeFromSuperView - 动画与否,当我发布@987654327 时,contentViewController 永远不会收到viewWillDisappear、viewDidDisappear 甚至viewDidUnload @;
有人知道为什么吗? 或者更好地了解 viewWill.../viewDid... 方法链以及它们应该被调用的时间。
【问题讨论】:
-
如果 CustomPopoverController 不是 UIViewController.. 那么什么是 CustomPopoverController?
self.contentViewController.view removeFromSuperview];我想会在 ContentViewController 中调用 viewWillDisappear -
@7KV7 - CustomPopoverController 是我自己的类,直接从 NSObject 派生。我的问题是 viewWillDisappear 没有按预期在 contentViewController 中调用。这正是我想要实现的目标。
标签: iphone objective-c ios ipad uiviewcontroller