Reputation: 988
I followed the SimpleDrillDown app example in the docs for a workout app that shows workout names in the first UITableView and exercises in the second UITableView.
My app is in Dropbox here: http://db.tt/V0EhVcAG
I used storyboards, have prototype cells, but when I load in simulator the first UITableView won't let me click and go to the detail UITableView. The disclosure indicator chevrons don't load. The app builds successfully and there are no formal errors.
My tableviews are in a navigation controller, my segue and prototype cells are all named accordingly in storyboard.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [dataController countOfList];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"WorkoutCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Workout *workoutAtIndex = [dataController objectInListAtIndex:indexPath.row];
cell.textLabel.text = workoutAtIndex.title;
return cell;
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showExercises"]) {
NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow];
DetailViewController *detailViewController = [segue destinationViewController];
detailViewController.workout = [dataController objectInListAtIndex:selectedRowIndex.row];
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [workout.exercises count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ExerciseCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [workout.exercises objectAtIndex:indexPath.row];
return cell;
}
#import <UIKit/UIKit.h>
@class DataController;
@class SpitfireViewController;
@interface SpitfireAppDelegate : UIResponder <UIApplicationDelegate>
{
UIWindow *window;
SpitfireViewController *spitfireViewController;
DataController *dataController;
}
@property (strong, nonatomic) UIWindow *window;
@end
#import "SpitfireAppDelegate.h"
#import "SpitfireViewController.h"
#import "DataController.h"
@implementation SpitfireAppDelegate
@synthesize window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
spitfireViewController = [[SpitfireViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:spitfireViewController];
DataController *controller = [[DataController alloc] init];
spitfireViewController.dataController = controller;
[window addSubview:[navController view]];
[self.window makeKeyAndVisible];
return YES;
}
@end
Upvotes: 2
Views: 6012
Reputation: 672
If you have tableview cell segue selection issue.
UITableViewDelegate
and UITableViewDataSource
when using "Static cells"Upvotes: 5
Reputation: 104092
I think this is your problem:
spitfireViewController = [[SpitfireViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:spitfireViewController];
DataController *controller = [[DataController alloc] init];
spitfireViewController.dataController = controller;
The spitfireViewController you create here is not the one in your storyboard, it's a new one. You should delete all this code, as you already have a spitfireViewController embedded in a navigation controller that you made in the storyboard. You should set the data controller for spitfireViewController in it's viewDidLoad method:
DataController *controller = [[DataController alloc] init];
self.dataController = controller;
Upvotes: 1
Reputation: 41001
When using Storyboards, you'll typically set the storyboard file name in the Project settings under the info tab. Once you've selected your storyboard there, you can basically delete everything except the return YES
part of the application:didFinishLaunchingWithOptions:
method. It's all taken care of for you in the storyboard.
EDIT:
Here's where you set the storyboard:
Also make sure that your view controller is set as the initial view controller:
Upvotes: 1
Reputation: 922
Where is your "didSelectRowAtIndexPath" method?
I would recommend putting that in and then triggering [self performSegueWithIdentifier:] to trigger the segue using the data in the table cell as the sender.
Upvotes: -1