Unrecognized selector sent to UIImage?

依然范特西╮ 提交于 2019-12-25 03:47:08

问题


hoping you can help me out. Code is Rubymotion but I'm pretty sure it's an iOS issue. Code is simple enough that hopefully it being Rubymotion doesn't get in the way of an answer. And I can read Obj-C, so if you can answer with Obj-C only, I'm good with that.

I have a UIImage object. I'm trying to get the size of it. When I do the following:

image = info.objectForKey(UIImagePickerControllerOriginalImage) 
@image = UIImage.alloc.initWithCIImage(image)
puts @image.to_s
puts @image.size
puts @image.to_s

I get this output:

#<UIImage:0x9513710>
NSInvalidArgumentException: -[UIImage extent]: unrecognized selector sent to instance 0x10fb7410 (RuntimeError)
#<UIImage:0x9513710>

I've read that when you get the extent error, it tends to mean the object has been released and is no longer in memory but if I comment out the .size line, the 3rd line still runs meaning it hasn't been released.

Any ideas?


回答1:


Somewhere you are using the UIImage instance rather than the CIImage instance... CIImage has a function called "Extent" on it (from a quick google) and UIImage doesn't. Maybe you're passing the image to a function which is using this "Extent" function.




回答2:


Thanks to Dave for leading me to this answer. The code needs to be written as @image.CIImage.size

This will work.



来源:https://stackoverflow.com/questions/15414635/unrecognized-selector-sent-to-uiimage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!