ios - 过渡时的 fatal error

标签 ios swift xcode uiviewanimationtransition

Error : "fatal error: unexpectedly found nil while unwrapping an Optional value" during transition between two view on same view controller

当我调用 Flip1 函数时,出现上述错误。

代码如下:

@IBAction func Flip(_ sender: AnyObject){
    UIView.transition(from: Back, to: Front, duration: 0.5, options: UIViewAnimationOptions.transitionFlipFromLeft, completion: nil)
}

@IBAction func Flip1(_ sender: AnyObject){
    UIView.transition(from: Front, to: Back, duration: 1, options: UIViewAnimationOptions.transitionFlipFromRight, completion: nil)
}

最佳答案

是的,我终于发现了错误。

只需将 outlet 设为强引用或弱引用即可:

@IBOutlet var Front: UIView!
@IBOutlet var Back: UIView!

完成了!

关于ios - 过渡时的 fatal error ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45566629/

相关文章:

ios - 应用程序运行一段时间后出现错误 3840 "JSON text did not start with array or object and option to allow fragments not set."

c++ - "' assert' was not declared in this scope"in MySQL++

ios - 将小按钮添加到单元格的右侧,指示下拉列表中的行数

ios - 如何更改 Mapbox 中目的地以外位置的标记?

ios - 使用 cordova 在 iOS 中播放图库中的视频

iOS ARC : unexpected 'dealloc' call

ios - 如何检查一个词是否在 Objective-C 中的短语中

ios - 隐藏键盘 IOS Swift

ios - 从背景进入前景时 SVProgressHUD 没有动画

ios - UICollectionView : Support for reordering on iOS 8