我的UIView控制器类在那里我已经在按钮单击事件中输出的视图导航,但按键编程方式创建一个UINavigationController的UINavigationController面临的一些问题
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Hmm";
navigationController = [[UINavigationController alloc] init];
//without this instruction, the tableView appears blocked
navigationController.view.frame = CGRectMake(0, 0, 768, 1004); // <-- nav controller should fill the screen
navigationController.navigationBar.barStyle = UIBarStyleDefault;
navigationController.title = @"Hello";
[navigationController.navigationBar setHidden:NO];
[self.view addSubview:navigationController.view];
CGRect frame = CGRectMake(100, 70, 200, 50);
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = frame;
[button setTitle:@"Bejoy" forState:UIControlStateNormal];
[button addTarget:self action:@selector(myButtonClick:) forControlEvents:(UIControlEvents)UIControlEventTouchDown];
[self.view addSubview:button];
}
现在
- (void)myButtonClick:(id)sender {
SAPRetailExCustomerSalesOrderDetailViewTVC *customerSalesOrderDetailViewTVC = [[SAPRetailExCustomerSalesOrderDetailViewTVC alloc] initWithNibName:@"SAPRetailExCustomerSalesOrderDetailViewTVC" bundle:nil];
[navigationController pushViewController:customerSalesOrderDetailViewTVC animated:YES];
[customerSalesOrderDetailViewTVC release];
}
这里仍然在我看来! 另外,我必须点击两次才能获得我的NavigationController中的后退按钮。 是因为我没有我的导航栏的标题。我将如何在这里设置标题? 有人可以帮助我吗?
“'[[UINavigationController的页头]初始化]'” 你为什么要这么做?只需使用'UINavigationController'即可:'initWithRootViewController:',或者在Interface Builder中创建一个,并将它的'Nib Name'设置为您的控制器类。永远不要用'init'创建一个'init类不在类文档中,所以你不应该认为你可以使用它。 – darvids0n