Reputation: 21
This is really frustrating as I've tinkered with previous versions of Xcode and have done this before but playing around with a new app now, it's not working for some reason.
I have the app open to a UITableView and want it to load to a detail UIView once I select a cell. However, when I choose a cell in the iPhone simulator, it just highlights the cell blue and doesn't load the view.
Here is the code I'm using the the RootViewController:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
WorkoutViewController *workoutViewController;
workoutViewController = [[WorkoutViewController alloc] initWithNibName:@"WorkoutViewController" bundle:nil];
workoutViewController.workoutName = [workouts objectAtIndex:indexPath.row];
[self.navigationController pushViewController:workoutViewController animated:YES];
[workoutViewController release];
workoutViewController = nil;
I have the view linked to the File Owner in the WorkoutViewController.xib file. When I put in a breakpoint at @implementation WorkoutViewController, it does get to that breakpoint but it goes to the @synthesize line and then jumps right back out to [self.navigationController ...etc]; and never returns back to the WorkoutViewController.m file.
Upvotes: 1
Views: 1413
Reputation: 21
Doh! Problem resolved. I had forgotten to actually put the RootViewController into a navigation controller on the MainWindow.xib. Appreciate the responses.
Upvotes: 1
Reputation: 5219
I would guess that you didn't set the ViewController to be the TableView's delegate. To check, open your ViewController xib-file and rightclick FilesOwner
. Under Referencing Outlet
you would usually have both delegate
and data
source" connected to your TableView
. If that is not the case, drag New Referencing Outlet
to your TableView.
If I'm wrong and they are all connected, you might want put a breakpoint at the beginning of your didSelectRowAtIndexPath
method. Does the debugger stop there, once you select a row?
It might also be worth mentioning that a breakpoint at @implementation
usually doesn't make much sense, you would rather want to place it in a method like init. Also, even though you are using Xcode 4 now, this is unlikely to be the cause of your problem, it looks more like an implementation issue.
Hope this helps, if you need further help just let me know!
Upvotes: 1