1

我正在尝试在 didSelectRowAtIndexPath: UITableView 的委托方法中从 NEOfficesRootViewController 推送 NEOfficesDetailViewController。这个 UITableView 附加了 NSFetherResultsController 。

在常见情况下一切正常, 但是如果我在 NSFetcherResultsController 的上下文发生变化(单个上下文,主线程上的所有更改)时多次点击表格的行,则 didSelectRowAtIndexPath: 方法将被多次调用,这将导致嵌套推送动画。

我还提到了一件奇怪的事情:didSelectRowAtIndexPath: 在所有上下文计算完成后被多次调用,似乎 UITableView 将我的点击保存在队列中,然后(当主线程空闲时)释放它们。因此,如果我在计算期间在表格视图的行上点击 4 次,didSelectRowAtIndexPath: 方法将在所有计算后调用 4 次。这是我的调试清单:

2013-01-04 16:41:14.038 nightexpress[858:707] connection created: YES
2013-01-04 16:41:14.414 nightexpress[858:707] NEOfficesRootViewController: viewDidAppear: called
2013-01-04 16:41:16.625 nightexpress[858:707] connection received response: 200 no error
2013-01-04 16:41:16.632 nightexpress[858:707] connection finish loading. data
2013-01-04 16:41:17.445 nightexpress[858:707] started deleting sequence
2013-01-04 16:41:17.460 nightexpress[858:707] finished deleting sequence
2013-01-04 16:41:17.463 nightexpress[858:707] starting saving sequence
2013-01-04 16:41:17.585 nightexpress[858:707] contextWillSave: called
2013-01-04 16:41:18.763 nightexpress[858:707] contextDidSave: called
2013-01-04 16:41:18.782 nightexpress[858:707] finished saving sequence
2013-01-04 16:41:18.784 nightexpress[858:707] officesUpdateSentAndReceivedResponse: called
2013-01-04 16:41:18.796 nightexpress[858:707] updateFetchingLocationUI called
2013-01-04 16:41:19.220 nightexpress[858:707] NEOfficesRootViewController: tableView:    didSelectRowAtIndexPath: 0 0
2013-01-04 16:41:19.261 nightexpress[858:707] NEOfficesDetailViewController: viewDidLoad: called
2013-01-04 16:41:19.266 nightexpress[858:707] NEOfficesDetailViewController: initializing scrollView content
2013-01-04 16:41:19.276 nightexpress[858:707] NEOfficesDetailViewController: updateFetchingLocationUI called
2013-01-04 16:41:19.279 nightexpress[858:707] NEOfficesDetailViewController: configureAndInstallAnotations called. initial annotation count: 0
2013-01-04 16:41:19.288 nightexpress[858:707] NEOfficesRootViewController: viewWillDisappear: called
2013-01-04 16:41:19.290 nightexpress[858:707] NEOfficesDetailViewController: viewWillAppear: called
2013-01-04 16:41:19.301 nightexpress[858:707] NEOfficesRootViewController: tableView: didSelectRowAtIndexPath: 0 1
2013-01-04 16:41:19.303 nightexpress[858:707] nested push animation can result in corrupted navigation bar
2013-01-04 16:41:19.310 nightexpress[858:707] NEOfficesRootViewController: tableView: didSelectRowAtIndexPath: 0 3
2013-01-04 16:41:19.313 nightexpress[858:707] nested push animation can result in corrupted navigation bar
2013-01-04 16:41:19.319 nightexpress[858:707] NEOfficesRootViewController: tableView: didSelectRowAtIndexPath: 0 6
2013-01-04 16:41:19.321 nightexpress[858:707] nested push animation can result in corrupted navigation bar
2013-01-04 16:41:19.328 nightexpress[858:707] NEOfficesRootViewController: tableView: didSelectRowAtIndexPath: 0 4
2013-01-04 16:41:19.330 nightexpress[858:707] nested push animation can result in corrupted navigation bar
2013-01-04 16:41:19.335 nightexpress[858:707] NEOfficesRootViewController: tableView: didSelectRowAtIndexPath: 0 3
2013-01-04 16:41:19.458 nightexpress[858:707] nested push animation can result in corrupted navigation bar
2013-01-04 16:41:19.469 nightexpress[858:707] NEOfficesRootViewController: tableView: didSelectRowAtIndexPath: 0 1
2013-01-04 16:41:19.470 nightexpress[858:707] nested push animation can result in corrupted navigation bar
2013-01-04 16:41:19.478 nightexpress[858:707] NEOfficesRootViewController: tableView: didSelectRowAtIndexPath: 0 3
2013-01-04 16:41:19.479 nightexpress[858:707] nested push animation can result in corrupted navigation bar
2013-01-04 16:41:19.486 nightexpress[858:707] NEOfficesRootViewController: tableView: didSelectRowAtIndexPath: 0 6
2013-01-04 16:41:19.488 nightexpress[858:707] nested push animation can result in corrupted navigation bar
2013-01-04 16:41:19.499 nightexpress[858:707] NEOfficesRootViewController: tableView: didSelectRowAtIndexPath: 0 7
2013-01-04 16:41:19.501 nightexpress[858:707] nested push animation can result in corrupted navigation bar
2013-01-04 16:41:19.978 nightexpress[858:707] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2013-01-04 16:41:19.982 nightexpress[858:707] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2013-01-04 16:41:19.984 nightexpress[858:707] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2013-01-04 16:41:19.985 nightexpress[858:707] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2013-01-04 16:41:19.993 nightexpress[858:707] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2013-01-04 16:41:19.995 nightexpress[858:707] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2013-01-04 16:41:19.997 nightexpress[858:707] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2013-01-04 16:41:20.000 nightexpress[858:707] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2013-01-04 16:41:20.002 nightexpress[858:707] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2013-01-04 16:41:20.012 nightexpress[858:707] Unbalanced calls to begin/end appearance transitions for <NEOfficesDetailViewController: 0x100fba70>.
4

3 回答 3

1

在获取数据时阻止用户交互。

在你开始获取之前放置一个阻止交互的视图,当获取完成时移除阻塞视图。

MBProgressHUD对此有好处。

于 2013-01-04T15:10:47.467 回答
0

通过用子视图覆盖 UI 或直接更改 userInteraction 来阻止 UI 将不会导致任何结果。使用 setDelaysContentTouches:NO UITableView 的方法为我解决了这个问题。

@Jeffery,感谢您的帮助。

于 2013-01-04T16:07:04.947 回答
0

[tableView setDelaysContentTouches:NO]; 是正确的答案...

于 2013-02-20T11:52:23.780 回答