首页 > 解决方案 > 当视图控制器中包含自定义视图时应用程序冻结

问题描述

当我将ProfileHeaderView作为子视图添加到 a时MDCFlexibleHeaderViewController,出现以下错误:

Thread 1: EXC_BAD_ACCESS (code=2, address=0x991fd4)

调用以下方法时会引发错误:

required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    self.commonInit()
}

调用super.init()方法时会调用错误。我没有看到控制台中打印出更多错误消息。关于如何解决它的任何想法?

仅供参考,ProfileHeaderView该类的代码如下所示:

class ProfileHeaderView: UIView {

@IBOutlet var header: ProfileHeaderView!

override init(frame: CGRect) {
    super.init(frame:frame)
    commonInit()
}

required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    self.commonInit()
}

private func commonInit(){
    Bundle.main.loadNibNamed("ProfileHeaderView", owner: self, options: nil)
    addSubview(header)
    header.frame = self.bounds
    header.autoresizingMask = [.flexibleHeight,.flexibleWidth]
}

/*
// Only override draw() if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func draw(_ rect: CGRect) {
    // Drawing code
}
*/

}

我不继承MDCFlexibleHeaderViewController.

错误日志

2018-10-02 22:19:14.179637-0500 builditbigger[564:444592] 5.4.1 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. 

Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
2018-10-02 22:19:14.179752-0500 builditbigger[564:444592] 5.4.1 - [Firebase/Analytics][I-ACS023007] Firebase Analytics v.50001000 started
2018-10-02 22:19:14.184430-0500 builditbigger[564:444592] 5.4.1 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see url)

标签: iosuiview

解决方案


推荐阅读