didSelectRowAtIndexPath:正在触发,但视图控制器不是。我尝试过不同的视图控制器,我知道它们正在工作。由于该方法正在解雇,我只能推测
[self.navigationController pushViewController:detailVC animated:YES];
未到达导航堆栈。
但我从tabbarcontroller调用Calendar View Controller,所以我不知道如何解决这个问题。
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound)];
GlobalSingleton *myAppID = [GlobalSingleton sharedSingleton];
myAppID.globalAppID = @"627";
UIViewController *calendarVC;
calendarVC = [[[CalendarViewController alloc] initWithNibName:@"CalendarViewController" bundle:nil] autorelease];
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = @[calendarVC];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
self.tabBarController.customizableViewControllers = nil;
return YES;
}
CalendarViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Row %@",[events objectAtIndex:indexPath.row] );
CalendarDetailVC *detailVC = [[CalendarDetailVC alloc] initWithNibName:@"CalendarDetailVC" bundle:nil];
detailVC.dictEvent = [events objectAtIndex:indexPath.row];
[self.navigationController pushViewController:detailVC animated:YES];
}
答案 0 :(得分:0)
您的层次结构中没有导航控制器,因此您无法推动。您需要添加一行来创建导航控制器,
calendarVC = [[[CalendarViewController alloc] initWithNibName:@"CalendarViewController" bundle:nil] autorelease];
UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController: calendarVC] autorelease];
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = @[nav];