Swift 3选择器使用

时间:2017-03-07 23:57:39

标签: swift3

我从Swift o version 3的旧版本转换后有了这段代码......

func ownCatalogBackButton() {
  // ...
}

我在同一个班级的其他地方

outletScoresDetailsNav.leftBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItemStyle.plain, target: self, action: #selector(self.ownCatalogBackButton(_:)));

但我收到错误

  

“ViewControllerScoresDetails”类型的值没有成员   ownCatalogBackButton

以防万一我误解了没有任何参数的函数的选择器语法,我也试过了:

outletScoresDetailsNav.leftBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItemStyle.plain, target: self, action: #selector(self.ownCatalogBackButton()));

outletScoresDetailsNav.leftBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItemStyle.plain, target: self, action: #selector(self.ownCatalogBackButton(:)));

outletScoresDetailsNav.leftBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItemStyle.plain, target: self, action: #selector(self.ownCatalogBackButton(_)));

转换后修复前1500个问题后,我的大脑必须被炒掉......这可能是造成这个错误的原因?

1 个答案:

答案 0 :(得分:0)

试试这个:

min-width