简体   繁体   English

Swift 2无法将UIView强制转换为GPUImageView

[英]Swift 2 failing to cast UIView to GPUImageView

I'm trying to use Brad Larson's amazing GPUImage framework in Swift 2 and having problems. 我正在尝试在Swift 2中使用Brad Larson出色的GPUImage框架,并且遇到了问题。 Being new to Swift (but fairly good in Obj-C) I'm not sure if it's a Swift or GPUImage bug or my ineptitude... 我是Swift的新手(但在Obj-C中相当不错),我不确定这是Swift还是GPUImage错误还是我的能力不足...

I've followed Brad's instructions for adding GPUImage as a framework in my iOS project (Xcode 7.0 beta 5), and on the whole things look good. 我已经按照Brad的说明在我的iOS项目(Xcode 7.0 beta 5)中添加了GPUImage作为框架,并且总体看来还不错。

But I then as a test put in the few lines of code on Brad's blog ( http://www.sunsetlakesoftware.com/2014/06/30/exploring-swift-using-gpuimage ) to try the 'tiny starting application' and although the app compiles OK, I get a runtime error (running on the device) of 但随后我作为测试在布拉德(Brad)的博客( http://www.sunsetlakesoftware.com/2014/06/30/exploring-swift-using-gpuimage )的几行代码中尝试了“小巧的启动应用程序”,并虽然应用程序编译正常,但出现了运行时错误(在设备上运行)

Could not cast value of type 'UIView' (0x19842b510) to 'GPUImageView' (0x10016b548).

I've used GPUImage successfully in Obj-C in the past so I understand the theory but this is new... Any ideas? 我过去在Obj-C中成功使用过GPUImage,所以我了解理论,但这是新的...有什么想法吗? Is this just an early Swift 2 issue, or an Xcode beta problem? 这仅仅是Swift 2的早期问题,还是Xcode beta的问题?

(Incidentally, in the code from Brad's blog page I did change the cast syntax from the Swift 1 as to the Swift 2 as! ) (顺便说一句,从Brad的博客页面的代码,我也从雨燕1改投语法as给斯威夫特2 as!

The answer: ensure self.view is set as a GPUImageView in the storyboard. 答案:确保将Story.board中的self.view设置为GPUImageView。 (Thanks Brad - unbelievable support as ever...) (感谢Brad-前所未有的支持...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM