내 프로젝트에서, 디스플레이 하단에 툴바에 다시 버튼을 추가하고 싶습니다.뒤로 버튼을 툴바로 빠르게 이동 하시겠습니까?
내 UIViewController가 내비게이션 컨트롤러에 내장되어 있으며 아래쪽 툴바가 있습니다. 하지만 뒤로 버튼은 기본적으로 탐색 컨트롤러의 왼쪽 상단 부분에 있습니다.
내 프로젝트에서, 디스플레이 하단에 툴바에 다시 버튼을 추가하고 싶습니다.뒤로 버튼을 툴바로 빠르게 이동 하시겠습니까?
내 UIViewController가 내비게이션 컨트롤러에 내장되어 있으며 아래쪽 툴바가 있습니다. 하지만 뒤로 버튼은 기본적으로 탐색 컨트롤러의 왼쪽 상단 부분에 있습니다.
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)
}
사용자 정의있는 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)
}
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)
}
이유는 애플 UI 가이드 라인은 무엇을 추천 달라? – NRitH
욕망은 아니지만 동의합니다. / –