我加入一個按鈕進入的UITableView通過執行以下操作可以在任何
// Add checkOut button
UIView *viewHolder = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 165)];
UIButton *checkOut = [UIButton buttonWithType:UIButtonTypeRoundedRect];
CGRect buttonRect = CGRectMake((self.view.frame.size.width - 220.)/2, 30, 220., 44.);
[checkOut setTitle:@"Check out" forState:UIControlStateNormal];
[checkOut addTarget:self action:@selector(goToCheckOut) forControlEvents:UIControlEventTouchUpInside];
[checkOut setFrame:buttonRect];
[viewHolder addSubview:checkOut];
self.shoppingListTable.tableFooterView = viewHolder;
和goToCheckOut不pushViewController:
#pragma mark - goToCheckOut
- (void)goToCheckOut {
NSLog(@"goToCheckOut");
AnotherViewController *controller = [[AnotherViewController alloc] initWithNibName:@"AnotherViewController" bundle:nil];
[self.navigationController pushViewController:controller animated:YES];
}
當我點擊該按鈕時,日誌中顯示
goToCheckOut
但我沒有被導航到另一個視圖控制器。
有沒有人知道爲什麼?請幫忙。謝謝
@pgb:你是有關如何的儀式。在標籤欄中的uiviewcontroller是我自己的視圖控制器...但是,我沒有uitabbarviewcontroller.Instead,我有uiviewcontroller
和uitabar
在它。要點擊每個uitab欄按鈕時顯示視圖,我做了如下
#pragma mark - TabBarDelegate
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
// firstViewController section
if (item.tag == 0) {
[self.firstViewController.view removeFromSuperview];
[self.secondViewControoler.view removeFromSuperview];
self.title = @"First View Controller";
[self.view insertSubview:self.firstViewController.view belowSubview:taBar];
}
// secondViewController section
else if (item.tag == 1){
[self.firstViewController.view removeFromSuperview];
[self.secondViewControoler.view removeFromSuperview];
self.title = @"Second View Controller";
frame.origin.x = [self horizontalCoordinateAt:item.tag + 2];
[self.view insertSubview:self.secondViewControoler.view belowSubview:taBar];
}
}
我遇到的當前結構現在是
UIViewController0 (it is also a navigationController)
UIViewController1
UIViewController2
UITabBar
FirstViewController
SecondViewController
它是如何可能改變,這樣我可以在第一和SecondViewController做pushViewController。
您的當前視圖控制器是否包含在導航控制器中?即'self.navigationController'不是'nil'? –
我只是仔細檢查,它不是。故事是我有一個大視圖A與4 uitabBars和這個視圖(包含uitableview +結帳按鈕的視圖)是當前視圖,當我點擊第三個uitabBar – tranvutuan
您的視圖不在導航控制器中?或'self.navigationController'不是零? –