在我的应用程序中,我的根视图控制器是 TabBar 控制器之一中的 TabBar 我使用表格视图我想在按下到单元格时推送视图控制器但是当我使用
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
TripDetailView * TripDetailViewObjec = [[TripDetailView alloc]init];
[self.navigationController pushViewController:TripDetailViewObjec animated:YES];
}
不做任何事情,因为Self.navigation=null
我尝试在 AppDelegate 中创建 UINavigationController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
AppDelegate * ApplicationDelegate =[[UIApplication sharedApplication]delegate];
[[ApplicationDelegate Nav] pushViewController:TripDetailViewObjec animated:YES];
}
我的 AppDelegate
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
WeekendTrips * WeekendTripsObject ;
UINavigationController * Nav;
}
@property (strong, nonatomic) UIWindow *window;
@property (strong,nonatomic) UINavigationController * Nav;
@end
@implementation AppDelegate
@synthesize Nav;
@synthesize window = _window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
WeekendTripsObject = [[WeekendTrips alloc]init];
Nav=[[UINavigationController alloc]initWithRootViewController:WeekendTripsObject];
[self.view addSubView Nav.view];
return YES;
}
这不起作用我能做什么?提前致谢