ios - 尝试在 Swift 中推送 View Controller 时崩溃

标签 ios swift uiviewcontroller viewcontroller

我遇到了一个奇怪的问题,当我尝试推送新的 View Controller 时,我的应用程序崩溃了。我已经设置了一个滑动手势,并希望在检测到滑动时转到另一个 View Controller 。当我运行这两行代码时...

let viewController:ViewController = ViewController()
self.navigationController?.pushViewController(viewController, animated: true)

应用程序崩溃并不是专门在这两行代码中,而是在我的 ViewController 类中,当我在 viewDidLoad 方法中运行这段代码时......

imageView.layer.masksToBounds = true

如果我注释掉它,当我设置文本字段的自动更正类型时,它会崩溃。我做错了什么?

最佳答案

当 View 立即崩溃时,我首先查看的位置是 InterfaceBuilder 中该 ViewController 的 Outlet。我寻找任何带有感叹号的内容。这通常意味着我重命名了 socket 或以某种方式断开了连接。按弄乱的项目旁边的小 x 删除任何损坏的内容。我会附上一张照片,以便您查看。

enter image description here

关于ios - 尝试在 Swift 中推送 View Controller 时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53484396/

相关文章:

ios - 在 iOS 中使用 Storyboard中的 .xib 文件调用 ViewController 时遇到问题

ios - "[Crashlytics:Crash] Reporting is disabled"

swift - 画外音 : can I adapt different voices tones in swift?

arrays - 随机选择一个类的实例化并显示?

ios - 在整个应用程序中设置 UILabel 的样式

ios - 如何在 UIPageViewController 中将元素从一个 View Controller 动画到另一个 View Controller ?

ios - 系统.ExecutionEngineException : Attempting to JIT compile method only in Debug Mode on device (MonoTouch)

objective-c - delaysContentTouches 仅在特定元素上而不进行子类化?

ios - iOS 应用程序能否以编程方式将 Apple Watch 置于飞行模式?

ios - 在 xcode 7 ios9 中未触发展开 segue Action