ios - UIPopoverController 显示 View 并在第二秒后关闭它

标签 ios objective-c iphone uipopovercontroller

我尝试使用弹出窗口显示 View 。由于 UIPopoverController 在 iPhone 上不起作用,我使用 WEPopoverController。

我的代码:

UIViewController *controller = [[UIStoryboard storyboardWithName:@"Main" bundle:nil]instantiateViewControllerWithIdentifier:@"GetDateController"];
controller.modalPresentationStyle = UIModalPresentationPopover;
WEPopoverController *pop = [[WEPopoverController alloc] initWithContentViewController:controller];
pop.delegate = self;
CGRect screen = [[UIScreen mainScreen]bounds];
CGRect r = CGRectMake(8, 8, screen.size.width-8, 57);
pop.popoverContentSize = r.size;
[pop presentPopoverFromRect:CGRectMake(200, 100, 0, 0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

当我启动该程序时,我看到一个弹出窗口,该窗口立即消失。 当我在 iPhone 上使用 UIPopoverController 程序崩溃时,在 iPad 上一切正常。

我需要对 WEPopoverController 做什么才能使其正常工作?

亚历山大。

最佳答案

那是因为view controller不拥有你创建的popover,没有强引用,ARC发现popover的引用计数为0,立即释放。您需要做的就是在创建后将弹出窗口作为 View Controller 的属性。

关于ios - UIPopoverController 显示 View 并在第二秒后关闭它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36788164/

相关文章:

ios - 在另一个获取中获取 Firebase

iphone - 在 Core Graphics 中绘制子弹箭头

ios - 广告标识符 [IDFA] 使用不当(限制广告跟踪)

iphone - UIView背景颜色

android - Cordova 项目可以在 Android 和 iPad 上运行,但不能在 iPhone 上运行

ios - UIPickerview 的 UITextfield 问题

objective-c - 添加行后立即开始编辑

iphone - iOS 两个不同的应用程序相互通信

iphone - 是否有任何关于 iOS Keychain 编程的详细记录的示例代码或文章?

iOS 崩溃与核心数据