• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - UIPopoverController 解雇的奇怪延迟

[复制链接]
菜鸟教程小白 发表于 2022-12-12 15:50:43 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

也许这纯粹是模拟器相关的。我还没有在实际设备上尝试过。

我使用的是最新款最棒的 MacBook,它配备 1TB 闪存驱动器、95% 可用的处理器,并且内存消耗低于全部内存消耗。

我有一个 UIPopoverController ,里面有 4 个项目,大小与这些项目相同。 相关的 UIPopoverController 中没有任何复杂的、多线程的或长时间运行的东西。

我已将出现和关闭动画设置为 0,但是当我点击列表中的某个项目时,弹出框消失时似乎存在 0 到 0.4 秒之间的随机不确定延迟。当然 0 是意料之中的,但接近半秒的时间明显更长且令人不安。

知道是什么原因造成的吗?

显示弹出框的代码...

-(IBAction)theLandImpsButtonPressedUIButton *)sender
{
    iRpNameValuePopover *thePopoverContent = [[iRpNameValuePopover alloc] init];
    thePopoverContent.theTableValues = [self getLandImpsChoicesList];
    impsLandPopover = [[UIPopoverController alloc] initWithContentViewController:thePopoverContent];
    thePopoverContent.thePopoverController = impsLandPopover;
    impsLandPopover.popoverContentSize = [iRpUIHelper sizeForPopoverThatHasTitle:NO andListContent:thePopoverContent.theTableValues];
    impsLandPopover.delegate = self;

    [impsLandPopover presentPopoverFromRect:self.theLandImpsButton.bounds inView:self.theLandImpsButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];
}

关闭弹出框的代码... 顺便说一句,这里没有评估时间 [self userChoiceIsValid] 因为它现在只是返回 YES。

-(void)tableViewUITableView *)tableView didSelectRowAtIndexPathNSIndexPath *)indexPath
{
    _theChosenNameValueItem = [self.theTableValues objectAtIndex:indexPath.row];
    [self acceptUserChoiceAndClose];
}


// This contentViewController is encapsulated INSIDE a UIPopoverViewController, and this class cannot itself
// close the popover which contains it, hence the need for the reference to the popover controller
// It is the popover's delegate... the one that created the popover, that is able to close it.
-(void)acceptUserChoiceAndClose
{
    _theUserChoseAValue = NO; // Start by assuming they didn't chose a valid value.

    if ([self userChoiceIsValid])
    {
        // Set variable that indicates the user chose a value which can be saved to core data, and/or presented on screen.
        _theUserChoseAValue = YES;

        // Close the popover.
        [_thePopoverController dismissPopoverAnimated:NO];

        // Notify the class that presented the popover that the popover has been dismissed.
        // It will still be available to the dismissal method where code can retrieve the user's choice, and set the popover to nil.
        if (_thePopoverController.delegate && [_thePopoverController.delegate respondsToSelectorselector(popoverControllerDidDismissPopover])
        {
            [_thePopoverController.delegate popoverControllerDidDismissPopover:_thePopoverController];
        }
    }
    else
    {
        [self showValidationFailureMessageToUser];
    }

}



Best Answer-推荐答案


在主线程中关闭 viewController 将解决问题。

dispatch_async(dispatch_get_main_queue(), ^{
        [self dismissViewControllerAnimated:YES completion:nil];
});

关于ios - UIPopoverController 解雇的奇怪延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31422980/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap