I have a BarTableViewController that derives from UITableViewController. It's my main view and so is loaded automatically when the app starts, and that instance of the class works fine.
Now I am trying to have that original instance push another instance of the same class like this:
BarTableViewController *bar = [[[BarViewController alloc] initForFoo:theFoo] autorelease];
[self.navigationController pushViewController:bar animated:YES];
The initForFoo method looks like this:
- (id)initForFoo:(Foo *)theFoo
{
if ((self = [self initWithNibName:@"BarTableViewController" bundle:nil])) {
self.foo = theFoo;
}
return self;
}
The push works and the view loads, and works fine in the simulator.
However on my iPhone 4 the table view is not responsive in this second instance: sliding my finger up and down the screen does nothing. If I tap in the search bar then tap cancel, the table then becomes responsive.
If I just call init instead if initWithNibName then the table view responds correctly even the first time, but of course none of my IBOutlet stuff gets bound.
This appears to be a one-time only thing: once I've done the search-and-cancel the table will respond, and even if I hit the back button then come back to this same instance of the view controller again, it won't get stuck.
What am I doing wrong here?
UPDATE: I did have this guy as RootViewController in my MainWindow.xib. I tried taking that out and making the app delegate create him, but still same behavior: everything works except for the table view not scrolling. But now the initial instance also is frozen.
So, whenever I explicitly called initWithNibName I get this frozen behavior.
UPDATE2: I've been commenting out different chunks of viewDidLoad and it seems to work all the time if I omit this:
[self.navigationController setToolbarHidden:NO animated:NO];
Of course that means I get no toolbar. I've tried putting it back in with no toolbar items, and it still exhibits the problem.
UPDATE3: Breaking in with GDB while it's in this state, this is what I find in the UITableView:
(gdb) p * [[[UIApplication sharedApplication] delegate] searchViewController] <UITableViewController> = { <UIViewController> = { <UIResponder> = { <NSObject> = { isa = 0x9fe44 }, <No data fields>}, members of UIViewController: _view = 0xa27600, _tabBarItem = 0x0, _navigationItem = 0x4d6dcc0, _toolbarItems = 0x0, _title = 0x0, _nibName = 0xb9120, _nibBundle = 0x242b40, _parentViewController = 0x4d6de90, _childViewControllers = 0x0, _childModalViewController = 0x0, _parentModalViewController = 0x0, _modalTransitionView = 0x0, _modalPreservedFirstResponder = 0x0, _defaultFirstResponder = 0x0, _dimmingView = 0x0, _dropShadowView = 0x0, _presentationSuperview = 0x0, _sheetView = 0x0, _currentAction = 0x0, _savedHeaderSuperview = 0x0, _savedFooterSuperview = 0x0, _editButtonItem = 0x0, _searchDisplayController = 0x4d7b290, _popoverController = 0x0, _modalTransitionStyle = UIModalTransitionStyleCoverVertical, _modalPresentationStyle = UIModalPresentationFullScreen, _lastKnownInterfaceOrientation = UIInterfaceOrientationPortrait, _contentSizeForViewInPopover = { width = 320, height = 1100 }, _formSheetSize = { width = 0, height = 0 }, _viewControllerFlags = { appearState = 2, isEditing = 0, isPerformingModalTransition = 0, hidesBottomBarWhenPushed = 0, autoresizesArchivedViewToFullSize = 0, viewLoadedFromControllerNib = 0, isRootViewController = 0, isSheet = 0, isSuspended = 0, wasApplicationFrameAtSuspend = 0, wantsFullScreenLayout = 0, shouldUseFullScreenLayout = 0, allowsAutorotation = 1, searchControllerRetained = 1, oldModalInPopover = 0, isModalInPopover = 0, restoreDeepestFirstResponder = 0, isInWillRotateCallback = 0, disallowMixedOrientationPresentations = 0, modalPresentationsAreCurrentContext = 0 } }, members of UITableViewController: _tableViewStyle = UITableViewStylePlain, _keyboardSupport = 0x4d87540, _tableViewControllerFlags = { clearsSelectionOnViewWillAppear = -1 } },
I've tried a few blind isFirstResponder stabs in gdb with no luck.