iOS7问题与模态视图控制器segue自定义单元格选择 [英] iOS7 issue with modal view controller segue from custom cell selection

查看:89
本文介绍了iOS7问题与模态视图控制器segue自定义单元格选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

After further investigation I thought it would be best to repost the question with more information on the sepcific issue.

此问题似乎仅在iOS7上发生。我已经在iOS6上测试了,这没有问题。

This issue seems to occur only on iOS7. I have tested on iOS6 and this works without issue.

- 设置
设置是你有一个 UIViewController (例如第一个VC),它包含一个tableView并且是数据源/委托。
当选择/点击tableView中的单元格时,执行第二视图控制器的segue(此时此时可能为空)。

-- Setup The setup is you have one UIViewController (first VC for example), this holds a tableView and is the datasource/delegate. When the cell in tableView is selected/tapped you perform a segue to the Second View Controller (this can be empty for now).

问题是segue不会立即发生。在预期的一秒钟内。在第二个视图控制器中没有传递数据或第二个视图控制器中正在加载的任何数据,因此您希望它是即时的。

The issue is that the segue does not occur immediately. Within a second as expected. There is no data being passed in the segue or anything being loaded in the second view controller so you expect it to be instant.

有时,这将正常工作,没有任何问题。
其他时候,你会点击单元格而不会发生任何事情。

Sometimes, this will work fine without any issues. Other times, you will click the cell and nothing will happen.

- 注意趋势
我注意到的是当'问题'发生了。模拟器/设备将等到下一分钟开始,然后强制通过模态视图控制器的负载。

问题发生后,您可以再次点击/点击设备屏幕上的任意位置以强制加载。

--Noticed Trend What I have noticed is that when the 'issue' occurs. The simulator/device will wait until the next minute begins then force through the load of the modal view controller. OR When the issue occurs you can click/tap again anywhere on the device screen to 'force' the load through.

问题可以只需要在基础知识的新项目中复制。我已上传了包含此项目的示例项目zip

The issue can be reproduced in a new project just with the basics in. I have uploaded a sample project zip that includes this.

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

I have a custom cell setup. When the cell is selected I perform the following:

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

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

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

I then have the following in the 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:]

Logging

Here are some example logs to show this: Run 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:发件人:]
2013-10-09 23:57:00.003 App [14954:a0b] - [SecondViewController viewDidLoad]

2013-10-09 23:57:00.003 App [14954:a0b] - [SecondViewController viewWillAppear: ]¥b $ b 2013-10-09 23:57:00.508 App [14954:a0b] - [SecondViewController viewDidAppear:]

Run 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:]

Run 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:]

推荐答案

填写雷达后Apple回复说:

After filling a Radar Apple responded with adding:

dispatch_async(dispatch_get_main_queue(), ^{});

到以下方法的结尾,这就是诀窍:

To the end of the following method, which does the trick:

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




在显示控制器的方法中,你可以安排一个no-op
块,它将强制runloop旋转,并且没有延迟。

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.

雷达参考号:15196237,随意提交另一份并参考此信息。

Radar Ref: 15196237, feel free to file another and reference this.

这篇关于iOS7问题与模态视图控制器segue自定义单元格选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆