我试图根据方向是横向还是纵向来触发segue。这就是我正在使用的,但它给了我一个未被识别的选择器错误。有人能指出我正确的方向吗?
viewDidLoad(){
UIDevice.currentDevice().beginGeneratingDeviceOrientationNotifications()
NSNotificationCenter.defaultCenter().addObserver(self, selector: "showScoreCard:", name: UIDeviceOrientationDidChangeNotification, object: nil)
}
func showScoreCard {
let deviceOrientation = UIDevice.currentDevice().orientation
if UIDeviceOrientationIsLandscape(deviceOrientation){
self.performSegueWithIdentifier("scorecardSegue", sender: self)
}
答案 0 :(得分:1)
删除showScoreCard
字符串末尾的冒号,因为冒号表示该方法只接受一个参数。