- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我为 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
在任何情况下都被调用 - 动画与否,contentViewController
永远不会收到 viewWillDisappear
,viewDidDisappear
甚至 viewDidUnload
当我释放 contentViewController
时;
有人知道为什么吗?或者甚至更好地了解 viewWill.../viewDid... 方法的链以及它们应该何时被调用。
最佳答案
当您通过 UIView 的方法添加 subview 或删除 subview 时,它永远不会导致拥有的 UIViewController
调用 viewWillAppear
, viewDidAppear
, viewWillDisappear
和 viewDidDisapper
。仅那些由 UINavigationController
方法管理的 viewController,如 pushViewController:animated:
或 popViewControllerAnimated:
,或 presentModelViewController:aniamted:
...等。他们将通知 Controller View 的状态正在更改。
关于iphone - viewWillDisappear 和 viewDidDisappear 永远不会被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5894576/
我在我的应用程序中使用导航 Controller 。我尝试单击一个按钮(不在导航栏中)的一个 UI viewWillDisappear 未被调用。但我没有使用 navigationController
我在选项卡 View 中有一个表单;我将任何字段的表单标记为已更改,如果表单是脏的(代替“保存”按钮),我想弹出一个带有“保存”/“取消”的 ActionSheet。在用户响应正在处理的 Action
我制作了一个播放器应用。当用户关闭应用程序(进入后台模式)并调用 viewWillDisappear 时,播放器停止播放音频。 我无法在 applicationDidEnterBackground 中
我有一个带有文本字段的 UITableviewController。文本字段包含必填字段。 如果用户没有输入所有字段就离开了屏幕,我想用 alertview 提醒用户。我在 viewwilldisap
我有一个 UIViewController,ViewControllerA,它显示为来自 RootViewController 类的模态视图 Controller 。 ViewControllerA
我的应用程序使用带有 splitviewcontroller 的 Storyboard。在左侧,我有带有选项列表的表格 View 。在右侧,我有一些关于左侧选项的信息。就像在设置应用程序中一样。当用户
我有一个带有两个简单屏幕的应用程序。第一个屏幕始终打开第二个屏幕的相同实例。第二个屏幕有一个文本字段和一个用于手动隐藏键盘的按钮。 viewWillDisappear 上的 resignFirstRe
我有一个 iOS 应用程序,它使用远程服务器上托管的数据库。 在 ViewWillDisappear 函数内执行数据库 INSERT 是否可能或只是不好的做法? 我似乎找不到太多有关 Apple 在该
我想在用户点击后退按钮返回到我的 Root View Controller 时执行动画。动画将简单地突出显示用户在详细 View Controller 中所做的更改。 我试过了。动画本身可以工作(对于
我是 Swift 的新手,我在我的应用程序中发现了一些奇怪的崩溃。 Fabric 报告说崩溃发生在 viewWillDisappear() 中。 我有两个 ViewControllers。用户在 A
在 viewWillDisappear 上,我需要更新很多 Core Data 记录,这样做会在我从一个 viewController 移动到另一个(通过 Tab View Controller)时造
所以我的应用程序中有一个 UINavController 并且我试图在用户按下后退按钮时执行一个方法。我到处搜索,只能找到断章取义的零碎内容。 有没有一种方法可以实现某种检查,在用户按下后退按钮关闭当
我需要检查 viewWillDisappear: 是否被调用,因为我将另一个 UIViewController 呈现为模态。有谁知道这是否可能? 更新 我想知道为什么要调用它。例如,如果它被弹出或者另
我有以下场景: 在 vcA 中(当用户点击 UI 中的按钮时): 使用 NIB 文件实例化 vcB -(当用户点击 UI 中的按钮时) 在 vcB 中初始化一个 iVar 使用 presentModa
是否有 viewWillDisappear 等同于 CCScenes ? 就像 onExit 等价于 viewDidDisappear 或 onEnter 等价于 viewDidAppear . 最佳
当我正在搜索然后切换 UItab 时,不会调用 ViewWillDisappear。知道为什么当我过滤结果显示和切换选项卡时 ViewWillDisappear 没有被调用吗? func update
这是之前 Unresolved 帖子的后续内容。我在 TableView 中有一个导航 Controller 、一个 TableView Controller 和一个搜索栏。所有这些都内置在 Stor
这是日志输出 2013-03-16 14:02:59.301 Echo[65406:4503] child viewWillDisappear start 2013-03-16 14:02:59.30
我有一个简单的导航层次结构: Controller 1 > Controller 2 > Controller 3 每个 Controller 都包含对其子级和父级的引用(@property(非原子,
我有一个包含 UIWebView 的 View ,它正在加载谷歌地图(所以有很多 JavaScript 等)。我遇到的问题是,如果用户在 Web View 完成加载之前点击导航栏上的“后退”按钮,我不
我是一名优秀的程序员,十分优秀!