gpt4 book ai didi

iOS7 问题与自定义单元格选择模态视图 Controller segue

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:02:58 26 4
gpt4 key购买 nike

最终编辑

经过进一步调查,我认为最好重新发布问题并提供有关特定问题的更多信息。

这个问题似乎只发生在 iOS7 上。我已经在 iOS6 上测试过,这没有问题。

-- 设置设置是你有一个 UIViewController(例如第一个 VC),它包含一个 tableView 并且是数据源/委托(delegate)。当 tableView 中的单元格被选择/点击时,您将执行到第二个 View Controller 的 segue(现在可以为空)。

问题

问题是 segue 不会立即发生。不出所料,一秒之内。 segue 中没有传递数据,第二个 View Controller 中没有加载任何数据,因此您希望它是即时的。

有时,这会正常工作而不会出现任何问题。其他时候,您单击单元格却什么也不会发生。

--注意趋势我注意到的是,当“问题”发生时。模拟器/设备将等到下一分钟开始,然后强制通过模态视图 Controller 的负载。要么出现问题时,您可以再次单击/点击设备屏幕上的任意位置以“强制”加载。

这个问题可以在一个新项目中重现,只要有基础知识。我有 uploaded a sample project zip that includes this .

附加代码(如果需要)

我有一个自定义单元格设置。选择单元格后,我执行以下操作:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"%s",__PRETTY_FUNCTION__);

if (indexPath.section == 0) {
[self performSegueWithIdentifier:@"selectGameTurnDiff" sender:self];
}
}

然后我在 prepareForSegue 中有以下内容:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSLog(@"%s",__PRETTY_FUNCTION__);
[super prepareForSegue:segue sender:sender];
}

记录

以下是一些示例日志来说明这一点:运行 1
2013-10-09 23:54:09.855 App[14954:a0b]-[FirstViewController tableView:didSelectRowAtIndexPath:]
2013-10-09 23:54:09.857 App[14954:a0b]-[FirstViewController prepareForSegue:sender:]
2013-10-09 23:55:00.004 App[14954:a0b]-[SecondViewController viewDidLoad]
2013-10-09 23:55:00.004 App[14954:a0b] -[SecondViewController viewWillAppear:]
2013-10-09 23:55:00.511 App[14954:a0b] -[SecondViewController viewDidAppear:]

运行 2
2013-10-09 23:56:21.900 App[14954:a0b]-[FirstViewController tableView:didSelectRowAtIndexPath:]
2013-10-09 23:56:21.901 App[14954:a0b] -[FirstViewController prepareForSegue:sender:]
2013-10-09 23:57:00.003 App[14954:a0b]-[SecondViewController viewDidLoad]
2013-10-09 23:57:00.003 App[14954:a0b]-[SecondViewController viewWillAppear:]
2013-10-09 23:57:00.508 App[14954:a0b] -[SecondViewController viewDidAppear:]

运行 3
2013-10-09 23:57:43.387 App[14954:a0b]-[FirstViewController tableView:didSelectRowAtIndexPath:]
2013-10-09 23:57:43.388 App[14954:a0b]-[FirstViewController prepareForSegue:sender:]
2013-10-09 23:58:00.004 App[14954:a0b]-[SecondViewController viewDidLoad]
2013-10-09 23:58:00.004 App[14954:a0b] -[SecondViewController viewWillAppear:]
2013-10-09 23:58:00.510 App[14954:a0b] -[SecondViewController viewDidAppear:]

最佳答案

在填充 Radar Apple 后回应添加:

dispatch_async(dispatch_get_main_queue(), ^{});

到下面方法的结尾,它起到了作用:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 

In the method that presents the controller, you can schedule a no-op block which will force the runloop to spin and there will be no delay.

Radar Ref:15196237,请随时提交另一个文件并引用此信息。

关于iOS7 问题与自定义单元格选择模态视图 Controller segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19283097/

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