私は1つのヘッダーファイルを持っています
@interface DemoFirstViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@end
このヘッダーファイルのソースファイルで、このメソッドを宣言しました
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
AnotherViewController *anotherViewController=[[AnotherViewController alloc] initWithNibName:@"AnotherViewController" bundle:nil];
[self.navigationController pushViewController:anotherViewController animated:YES];
NSLog(@"didSelectRowAtIndexPath: row=%d", indexPath.row);
}
そしてanotherViewControllerファイルは
@interface AnotherViewController : UIViewController
{
IBOutlet UILabel *message;
}
@property (nonatomic , retain) UILabel *message;
@end
私はこれをすべてXibファイルを使用して行っています。ストーリーボードではありません。
これはtabbased Application
です。および2つのビューコントローラはすでにAppdelegateで宣言されています
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController *viewController1 = [[DemoFirstViewController alloc] initWithNibName:@"DemoFirstViewController" bundle:nil];
UIViewController *viewController2 = [[DemoSecondViewController alloc] initWithNibName:@"DemoSecondViewController" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[viewController1, viewController2];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
テーブルセルをタップすると、anotherViewcontrollerが起動しません。Plzはできるだけ早く返信します。