我試圖創建一個視圖控制器,並設置其視圖和標題欄。事情似乎工作得很好。但是,當我嘗試設置導航欄的左側按鈕或右側按鈕時,他們只是不顯示。我究竟做錯了什麼?添加按鈕不顯示在UINavigationController上
UIWebView *tempWebView = [[UIWebView alloc] initWithFrame:self.view.bounds];
[tempWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"someurl"]]];
UIViewController* tempViewController = [[UIViewController alloc]init];
tempViewController.view = tempWebView;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:tempViewController];
UIBarButtonItem* closeButton = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:nil];
navigationController.navigationItem.leftBarButtonItem = closeButton;
[self presentViewController:navigationController animated:YES completion:nil];
這有助於我使用ParentViewController設置左鍵按鈕 – Irwin