gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 12:01:34 25 4
gpt4 key购买 nike

我尝试使用弹出窗口显示 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com