ios - UIButton 在 View Controller 上不起作用

标签 ios swift uibutton

我有两个 UIButton位于我的 View Controller 和每个按钮上,我以编程方式添加了 instantiateViewControllerWithIdentifier每个按钮的方法。但是,当我构建和运行项目时,我点击每个按钮但没有任何 react (见屏幕截图)。我尝试了多种方法来试图找出问题,其中一种方法是添加 print查看 debug 中是否出现任何内容盒子,但什么都没有!

值得一提的是,在这个 View Controller 上,我有一个连续的视频。

这是我当前的代码:

    @IBAction func CreateAccount(sender: AnyObject) {

    let vc = self.storyboard!.instantiateViewControllerWithIdentifier("signup") as! SignUpNavController
    self.presentViewController(vc, animated: true, completion: nil)

    print("Clicked!")
}

以下是我构建和运行项目时发生的情况:

enter image description here

更新:
enter image description here

最佳答案

回到你的界面构建器( Storyboard或 xib)。右键单击 View Controller 并仔细检查 IBAction 是否正确连接。如果是这样,那么在 viewDidLoad 中放置一个断点以确保按钮的 IBOutlets 不为零。

关于ios - UIButton 在 View Controller 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36413044/

相关文章:

Swift泛型函数根据泛型类型调用底层方法

ios - 在 Swift 中,改编了 AVCaptureVideoDataOutputSampleBufferDelegate,但从未调用 captureOutput

ios - UITextView,带有拼写检查,如何使用 `ignoreWord` ?

ios - 向后滑动太快时 UIButton 的标题神秘消失

ios - Little-Endian 字节顺序(iOS,BLE 扫描响应)

ios - CGContextShowTextAtPoint 即使在不同的迭代中也有固定的大小?

ios - 为什么 Xcode 中的控制台不能使用点符号打印我的对象的属性?

ios - 更改自定义 UIButton 状态时的 UI 问题

ios - 我如何绘制两条线之间有一定角度的线,以后可以通过拖动任何线来改变角度

ios - 从 plist 中以 segue 方式传递数据。 TableView 到详细信息 View