最初の UITableView にワークアウト名を表示し、2 番目の UITableView にエクササイズを表示するワークアウト アプリのドキュメントの SimpleDrillDown アプリの例に従いました。
私のアプリは Dropbox にあります: http://db.tt/V0EhVcAG
私はストーリーボードを使用し、プロトタイプセルを持っていますが、シミュレーターにロードすると、最初の UITableView をクリックして詳細 UITableView に移動できません。開示インジケーターのシェブロンが読み込まれません。アプリは正常にビルドされ、正式なエラーはありません。
私のテーブルビューはナビゲーションコントローラーにあり、セグエとプロトタイプのセルはすべてストーリーボードでそれに応じて名前が付けられています。
SpitfireViewController.m
- (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];
}
}
DetailViewController.m
- (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;
}
AppDelegate.h
#import <UIKit/UIKit.h>
@class DataController;
@class SpitfireViewController;
@interface SpitfireAppDelegate : UIResponder <UIApplicationDelegate>
{
UIWindow *window;
SpitfireViewController *spitfireViewController;
DataController *dataController;
}
@property (strong, nonatomic) UIWindow *window;
@end
AppDelegate.m
#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