斯威夫特,在定向旋转时消防

时间:2014-09-18 22:56:35

标签: swift orientation

我试图根据方向是横向还是纵向来触发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)

 }

1 个答案:

答案 0 :(得分:1)

删除showScoreCard字符串末尾的冒号,因为冒号表示该方法只接受一个参数。