user1897723
user1897723

Reputation: 181

didSelectRowAtIndexPath: nested push animations

I'm trying to push NEOfficesDetailViewController from NEOfficesRootViewController in didSelectRowAtIndexPath: UITableView's delegate method. This UITableView has NSFectherResultsController attached to it.

Everything works fine in the common situation, but if I tap multiple times on the table's row while my NSFetcherResultsController's context is changing (single context, all changes on the main thread) the didSelectRowAtIndexPath: method will be called multiple times and this will results in nested push animations.

Also I've mentioned a strange thing: didSelectRowAtIndexPath: gets called multiple time after all the context calculations will finish, it seems like UITableView saves my taps in queue and then (when the main thread becomes free) releases them. So If I will tap 4 times on the table view's row during my calculations didSelectRowAtIndexPath: method will be called 4 times after all the calculations. Here's my debug listing:

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>.

Upvotes: 1

Views: 946

Answers (3)

Vikas Maini
Vikas Maini

Reputation: 45

[tableView setDelaysContentTouches:NO]; is the correct answer...

Upvotes: 0

user1897723
user1897723

Reputation: 181

blocking UI by covering it with subview or changing userInteraction directly will result in nothing. using setDelaysContentTouches:NO UITableView's method solved the problem for me.

@Jeffery, thanks you for assistance.

Upvotes: 0

Jeffery Thomas
Jeffery Thomas

Reputation: 42598

Block user interaction while fetching data.

Before you start the fetch put up an view that block interaction, when the fetch finishes remove the blocking view.

MBProgressHUD is good for this.

Upvotes: 1

Related Questions