我正在尝试使用Storyboard将PHLivePhotoView
放入WelcomeVideoItemViewController
中。为此,配置了带有自定义类的视图:
自定义View Controller的实现:
class WelcomeVideoItemViewController: UIViewController, PHLivePhotoViewDelegate {
@IBOutlet weak var livePhotoView: PHLivePhotoView!
@IBOutlet weak var tipImageView: UIImageView!
@IBOutlet weak var tipLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
print(livePhotoView)
// Optional(<UIView: 0x7fd161f200b0; frame = (0 0; 320 568); autoresize = RM+BM; layer = <CALayer: 0x60000134ac60>>)
// Crash here
livePhotoView.delegate = self
}
}
因此,问题在于livePhotoView
用UIView
实例初始化,这导致崩溃,因为UIView
没有delegate
属性。我可以让这个自定义类起作用吗?
Xcode 10.2,iOS 12.2,Swift 4.2