テーブルに問題があり、ユーザーがテーブルのセルに触れると別のビューが表示されます。メイン ビューに UITabBarController を使用して、さまざまなビューを表示しています。次に、ユーザーが UITableView ビューを選択してテーブル セルの選択から次のビューを表示するときに、UINavigationController を使用します。
私の問題は次のとおりです。表のセルを選択すると、セルが強調表示され、次のビューが表示されません。IBを使用しています。私が見つけたすべての例は、例が機能することを除いて、私と同じ方法でこれを行っています!
ディクショナリを使用して NSMutableArray にコントローラをロードしました。また、配列項目を使用するのではなく、View Controller を直接作成して、このコードを試しました。同じ結果....
対象のコントローラー(Calc1ViewController)をチェックして、コントローラーに異常がないことを確認しました。直接表示すると、コントローラー (Calc1ViewController) が正しく表示されます。
ここにいくつかのコードがあります.....
ディクショナリ内のビュー コントローラの初期化:
Calc1ViewController *calc1ViewController = [[Calc1ViewController alloc] init];
[menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
NSLocalizedString(@"SSC - page 1",@""), @"title",
calc1ViewController, @"viewController",
nil]];
[calc1ViewController release];
また、辞書を使用せずにこれを試しました- [[menuList objectAtIndex:...]; の代わりにビューコントローラーを作成します。行 -- 次のようにビュー コントローラを作成します。
Calc1ViewController *targetViewController = [[Calc1ViewController alloc] init];
// the table's selection has changed, switch to that item's UIViewController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *targetViewController = [[menuList objectAtIndex: indexPath.row] objectForKey:@"viewController"];
[[self navigationController] pushViewController:targetViewController animated:YES];
targetViewController = nil;
}
ナビゲーション コントローラーは AppDelegate で定義され、IB を介して RootViewController に接続されます。
テーブルの行を選択すると、pushViewController コードが実行されたことがデバッガーに表示されますが、次のビューは表示されません。次に例を示します。
代替テキスト http://thecoolestcompany.com/ssc-table-view.jpg
何か案は?