在模态转换后不调用IBAction

时间:2015-02-09 07:07:57

标签: ios swift ios8 xcode6 ibaction

我的导航栏上有以下IBActions

    @IBAction func logoutPressed(sender: AnyObject) {

    SweetAlert().showAlert("Are you sure?", subTitle: "Do you really want to logout?", style: AlertStyle.Warning, buttonTitle:"Cancel", buttonColor:UIColorFromRGB(0xD0D0D0) , otherButtonTitle:  "Yep", otherButtonColor: UIColorFromRGB(0xDD6B55)) { (isOtherButton) -> Void in
        if isOtherButton == false {
            let popTime = dispatch_time(DISPATCH_TIME_NOW, Int64( Double(NSEC_PER_SEC) * 4.0 ))
            SwiftSpinner.show("Logging out")
            dispatch_after(popTime, dispatch_get_main_queue(), {
                PFUser.logOut()
                self.performSegueWithIdentifier("logoutSegue", sender: nil)
                SwiftSpinner.hide()

            })
        }
        else {
        }
    }

    }

//OPTIONS MENU
@IBAction func optionsPressed(sender: AnyObject) {
    let alert = SCLAlertView()
    alert.addButton("Submit Feedback"){
        var subjectText = "feedback"
        var toRecipient = ["some email address"]
        var mc:MFMailComposeViewController = MFMailComposeViewController()
        mc.mailComposeDelegate = self
        mc.setSubject(subjectText)
        mc.setToRecipients(toRecipient)
        self.presentViewController(mc, animated: true, completion: nil)
    }
    alert.addButton("About") {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let vc = storyboard.instantiateViewControllerWithIdentifier("about") as UIViewController
        self.presentViewController(vc, animated: true, completion: nil)
    }

依旧......

当我将应用程序启动到包含这些IBActions的视图控制器时,这非常正常。 然而,问题是当我执行模态/推送转换到所述视图控制器时,IBAction没有被调用....

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

我刚刚处理了这个问题,可能不是一般的解决方案,对我来说这是一个愚蠢的错误,但问题是我改变了ViewController中'view'的类: ViewHeirarchy

突出显示的视图被命名为其他内容,直到我在身份检查器中将其更改回UIView:

identityInspector

希望能帮助你或其他人:)