我有一个基于导航的模板,我们在其中获取默认文件appdelegate.h,.m文件和rootviewcontroller.h和.m文件。现在我已经在项目中要求rootviewcontroller仅在应用程序安装在设备中时首次显示。在rootviewcontroller我有按钮o点击事件,我添加新视图作为子视图。在新视图中,我有一个按钮,可以进一步查看新视图。要进行新视图,我使用[self.navigationcontroller pushviewcontroller:new_view1 animated:YES]但这不起作用。意味着不推视。我怎么修理它?
在appdelegate文件中,我使用此代码进行didfinish启动: -
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
并在按钮上单击rootviewcontroller我使用此代码: -
- (void)parser{
main_view_obj=[[Home_Screen_viewController alloc] initWithNibName:@"Home_Screen_viewController" bundle:nil];
[self.view addSubview:main_view_obj.view];
}
结束主视图的按钮clikc我使用此代码: -
-(IBAction)accounts{
[appDelegate startProgressBar:@"while loading data..."];
account_view =[[Account_login_viewController alloc] initWithNibName:@"Account_login_viewController" bundle:Nil];
[self.navigationController pushViewController:account_view animated:YES ];
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Home" style:UIBarButtonItemStyleBordered target:nil action:nil] autorelease];
[appDelegate endProgressBar];
}
现在的问题是[self.navigationController pushViewController:account_view animated:YES]无效。如何解决?
答案 0 :(得分:0)
试试这个,它会起作用
-(IBAction)accounts{
[appDelegate startProgressBar:@"while loading data..."];
account_view =[[Account_login_viewController alloc] initWithNibName:@"Account_login_viewController" bundle:Nil];
[appDelegate.navigationController pushViewController:account_view animated:YES ];
appDelegate.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Home" style:UIBarButtonItemStyleBordered target:nil action:nil] autorelease];
[appDelegate endProgressBar];
}