我的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