问题描述
代码:
import UIKit
class ViewController: UIViewController{
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.leftBarButtonItem=UIBarButtonItem(
title: "Back",
style: UIBarButtonItem.Style.plain,
target: self,
action: Selector("backButtonItemToDismissModal"))
}
func backButtonItemToDismissModal(){
// self.dismiss(animated:true)
self.dismiss(animated: true, completion: { () -> Void in
}
)
}
}
解决方法
import UIKit
class ViewController: UIViewController{
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.leftBarButtonItem=UIBarButtonItem(
title: "Back",
style: UIBarButtonItem.Style.plain,
target: self,
action: #selector(self.backButtonItemToDismissModal))
}
@objc func backButtonItemToDismissModal(){
// self.dismiss(animated:true)
self.dismiss(animated: true, completion: { () -> Void in
}
)
}
}
reference: https://code-examples.net/en/q/227c24b