views:

583

answers:

1

hey all, I'm very confused here, i've been trying to figure this one out. I have a UIViewController, viewControllerBrowse, with two TableViewController, Designations & Types, I call a second UIViewController, viewControllerSelectLibrary, that makes some SOLite operations and fills two arrays from where the first two TableView feed.

When I'm going to call back viewControllerBrowse, I perform inside a NSThread:

[appDelegate.viewControllerBrowse.tvcTypes.tableView reloadData];
[appDelegate.viewControllerBrowse.tvcTypes.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];

[appDelegate.viewControllerBrowse.tvcDesignations.tableView reloadData];

[appDelegate.viewControllerBrowse.tvcDesignations.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];

What TRUUUULY puzzles me is that on tvcTypes case, its tableView gets its first row selected and scrolled to the top

BUT, for tvcDesignations, its tableView get ITS FIRST ROW SELECTED BUT IT DOES NOT SCROLL TO THE TOP

the fact that the first row is selected tells me that it's not a problem of reference in the appDelegate, it's as if only half the method is working/??????????????

anyone hit this one before??????

+1  A: 

Just a guess, but what happens if you pass NO to animated? I've never seen this behavior specifically, unfortunately, but I have seen some animations cause weird interactions.

Also, which view controller is visible? Either of them?

NilObject
sir, you NAILED it, works fine not, but it's STRANGE given that BOTH TableViews where on the same ViewController (viewControllerBrowse, set as a property on the appDelegate and Root of a UINavigationController) and the code worked before moving it to a NSThread. It also didn't matter whether I called selectToRowAtIndexPath on tvcTypes or tvcDesignations first. WEIRD.regarding your question, appDelegate.window only has UINavigationController with viewControllerBrowse (where the two Tableviews are) as Root, from there i push to viewControllerSelectLibrary, do some SQLITE work, DID THE ...
dhomes
selectRowAtIndexPath on a ref to viewControllerBrowse and then popToRootit was all working before, just moved it as i mentioned to an NSThread
dhomes
Ah, I missed the thread part. UIKit isn't threadsafe, so calling UIKit methods inside of a thread will yield unpredictable results. You'll need to somehow signal to the main thread that this operation needs to occur, such as using one of the performSelectorOnMainThread:withObject: variants
NilObject
oh! thanks for the info, i am getting a weird memory leak from within this thread when i call the reloadData method of the tableViewControllers.tableView. it may come from this.
dhomes