xcode - 关闭模态视图 Swift

标签 xcode debugging swift modal-dialog xcode6

编辑:感谢下面答案背后的人,他修复了未知类。但是,谁能告诉我解雇代码是否正确?我正在度假,回来之前无法编程。

我正在用 Swift 开发一个应用程序。目前,我正在处理一个信息屏幕(法律声明、信用、文档等),它将以模态方式显示在主屏幕的顶部。

预期的行为是,当按下按钮触发 InfoViewController 中的 Dismiss 时,模态视图 Controller 将被关闭。

这是我尝试使用的代码:

//This is InfoViewController, the swift file used to conorol the info screen.

import UIKit

class InfoViewController: UIViewController {

    @IBAction func Dismiss(sender: AnyObject) {
        self.dismissViewControllerAnimated(true, completion: {});//This is intended to dismiss the Info sceen.
        println("pressed")
    }
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

}

这是 Storyboard的布局:

postimg.org/image/wbozsmtr3/

当我按下按钮时,应用程序崩溃并且没有关闭模态视图 Controller 。

它编译,表明它不是语法错误。

这是 LLVM 调试器的输出:

2014-08-30 20:02:20.571 CryptoCalc[799:244086] 17545849:_UIScreenEdgePanRecognizerEdgeSettings.edgeRegionSize=13.000000 //Unrelated stuff deleted. 2014-08-30 20:03:03.756 CryptoCalc[799:244086] Unknown class InfoViewController in Interface Builder file. 2014-08-30 20:03:20.485 CryptoCalc[799:244086] -[UIViewController Dismiss:]: unrecognized selector sent to instance 0x14d57990 2014-08-30 20:03:20.489 CryptoCalc[799:244086] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController Dismiss:]: unrecognized selector sent to instance 0x14d57990' * First throw call stack: (0x2238be2f 0x2f46bc8b 0x22391179 0x2238f097 0x222c11f8 0x259b9fef 0x259b9f91 0x259a4d13 0x259b99fd 0x259b96d7 0x259b2fa1 0x25989a09 0x25bfbae3 0x259884a1 0x2235257f 0x2235198f 0x2234fff5 0x2229e611 0x2229e423 0x297f80a9 0x259e8485 0x73720 0x7375c 0x2f9f1aaf) libc++abi.dylib: terminating with uncaught exception of type NSException

如果您需要更多信息,请告诉我。非常感谢。

最佳答案

这里的主要问题是 Interface Builder 文件中的未知类 InfoViewController。

您需要确保(在“自定义类”部分)

1) Storyboard中的类设置为InfoViewController

2) 模块设置为'Current - 你的项目名称'

屏幕截图包括显示我指的是 Interface builder 的哪一部分

enter image description here

关于xcode - 关闭模态视图 Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25587993/

相关文章:

ios - 如何从 Xcode 项目中删除 Firebase Analytics 依赖项?

debugging - pyspark 数据帧方法(即 show())无法在 VS Code 调试控制台中打印

debugging - 网络 Storm 调试?

ios - Travis CI 失败 iOS 构建

ios - Swift Firebase 持久化

xcode - 如何使用 MouseDown 更改场景

ios - 可以在不使用 StoryBoard 的情况下执行 segue 吗?

c++ - XCode 升级到 4.4.1,现在我在 STL <vector> 中编译时遇到错误

c++ - 使用 IPython 调试 C/C++ 代码

ios - 在 UIStackView 中设置 anchor 和位置