2016-11-01 3 views
0

私のプロジェクトでは、表示の最後にツールバーのボタンを追加したいと思います。戻るボタンをツールバーに移動しますか?

私はUIViewControllerをNavigation Controllerの中に埋め込みました。また、私はボトムツールバーを持っています。しかし、ナビゲーションコントローラの左上部分には、デフォルトで戻るボタンがあります。

+0

なぜAppleのUIガイドラインは何をお勧めします変更しますか? – NRitH

+0

欲望はありませんが、私は同意します:/ –

答えて

1

navBatからツールバーに戻るボタンは移動できませんが、カスタムボタンを追加できます。

self.tabBarController?.navigationItem.hidesBackButton = true 
self.navigationController?.toolbarHidden = false 
var items = [UIBarButtonItem]() 
items.append(
    UIBarButtonItem(title: "Back", style: .Plain, target: self, action: #selector(gotoBack)) 
) 
self.navigationController?.toolbar.items = items 

func gotoBack(){ 
    self.navigationController?.popViewController(animated: true) 
} 
0

カスタムnavigationController

スウィフト3.0

NextViewCでNavViewController.swift

class NavViewController: UINavigationController,UINavigationControllerDelegate { 

    var _delegate:UIGestureRecognizerDelegate? 


    override func viewDidLoad() { 
     super.viewDidLoad() 

     _delegate = self.interactivePopGestureRecognizer?.delegate 
     self.delegate = self 

    } 



     func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) { 
//Because it can slide 
      if viewController != navigationController.viewControllers[0] { 
       viewController.navigationController?.interactivePopGestureRecognizer?.delegate = nil; 
      }else{ 
       viewController.navigationController?.interactivePopGestureRecognizer?.delegate = _delegate; 
      } 
     } 
    } 

でのViewController機能に追加ontroller.swift

override func viewDidLoad() { 
     super.viewDidLoad() 
     self.navigationItem.hidesBackButton = true 
     // Do any additional setup after loading the view. 
    } 
    @IBAction func BackButtonItem(_ sender: UIBarButtonItem) { 
     _ = navigationController?.popViewController(animated: true) 
    } 
0
let toolbar = UIToolbar (frame: CGRect(x: 0, y: 0, width: 
self.view.frame.size.width, height: 56)) 

    toolbar.barStyle = UIBarStyle.black 
    toolbar.sizeToFit() 

    var items = [UIBarButtonItem]() 

    items.append(
     UIBarButtonItem(title: "Back", style: .plain, target: self, action: #selector(Viewcontroller.BackClicked(sender:))) 
    ) 
    toolbar.setItems(items, animated: true) 
    toolbar.tintColor = UIColor.black 
self.navigationController?.navigationItem.hidesBackButton = true 

self.navigationController?.toolbar.itemsの=項目

func BackClicked(sender: UIBarButtonItem) 

{ 
    _ = navigationController?.popViewController(animated: true) 

} 
関連する問題