我正在練習帶導航欄得應用程序.我使用UIBarButton從主屏幕轉到下一個屏幕.
UIButton *moveLeft = [UIButton buttonWithType:UIButtonTypeCustom]; [moveLeft setTitle:@"Next Screen" forState:UIControlStateNormal]; moveLeft.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:12.0f]; [moveLeft.layer setCornerRadius:4.0f]; [moveLeft.layer setBorderWidth:1.0f]; [moveLeft.layer setBorderColor: [[UIColor redColor] CGColor]]; moveLeft.frame=CGRectMake(200,100.0,90.0,30.0); [moveLeft setTitleColor:[UIColor greenColor] forState:UIControlStateNormal]; [moveLeft addTarget:self action:@selector(moveToNext) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem* barbutton= [[UIBarButtonItem alloc] initWithCustomView:moveLeft]; self.navigationItem.rightBarButtonItem = barbutton;
但現在當第二個屏幕出現時,沒有導航欄.
以下是該應用得屏幕截圖
我也嘗試了UIBarButton,但第二個屏幕上仍然沒有導航欄.
UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil]; [[self navigationItem] setBackBarButtonItem:back];
我得問題如何在第二個屏幕上顯示后退按鈕?我沒有制作任何自定義按鈕,但默認也不會自動進入.
請指導我.
解決方法
從您得評論中,您將呈現下一個視圖控制器,而不是這個
[self presentViewController:secondScreen animated:YES completion:nil];
這樣做
[self.navigationController pushViewController:secondScreen animated:YES]
建議
您應該設置窗口得rootViewController,而不是將subView添加到窗口中.所以改變
[self.window addSubview:[navControll view]];
至
self.window.rootViewController = navControll;
以上是來客網為你收集整理得ios – 如何在導航欄上顯示返回按鈕?全部內容,希望內容能夠幫你解決ios – 如何在導航欄上顯示返回按鈕?所遇到得程序開發問題。
如果覺得來客網網站內容還不錯,歡迎將來客網網站推薦給程序員好友。
聲明:所有內容來自互聯網搜索結果,不保證100%準確性,僅供參考。如若本站內容侵犯了原著者的合法權益,可聯系我們進行處理。