EKEventViewController导航栏中的Swift自定义后退按钮

时间:2017-01-04 07:46:58

标签: ios swift xcode

我在我们的应用程序中使用了EKEventViewController。 代码应该如下

class MyEkEventViewController: EKEventViewController {
        override func viewDidLoad() {
           super.viewDidLoad()
           let cancelButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.cancel, target: self, action: #selector(MyEkEventViewController.cancel))
           self.navigationController?.navigationItem.setLeftBarButton(cancelButton, animated: false)
          //self.navigationController?.navigationItem.leftBarButtonItem = cancelButton
    }
}

@objc fileprivate func cancel() {
        _ = navigationController?.popViewController(animated: true)
    }
}  

   # My invocation   
   .
   .
   .
    let eventViewController = MyEkEventViewController()
        eventViewController.delegate = self
               eventViewController.allowsEditing = true
        eventViewController.allowsCalendarPreview = true
        eventViewController.hidesBottomBarWhenPushed = true
        eventViewController.event = event
        self.navigationController?.pushViewController(eventViewController, animated: true)

仅显示后退箭头。但是“取消”按钮不会显示在左侧导航栏中。

Sample screen shot here

0 个答案:

没有答案