LBBlurredImage NSInvalidArgumentException

时间:2015-01-26 23:53:37

标签: swift uiimageview uiimage

我使用以下库:

https://github.com/lukabernardi/LBBlurredImage

这是我用来模糊我添加到ViewController的背景图片的代码:

var background = UIImage(named: "bg")
var backgroundImageView = UIImageView(image: background)
backgroundImageView.contentMode = .ScaleAspectFill;
backgroundImageView.setImageToBlur(background, blurRadius: 10, completionBlock: { () -> Void in
    println("The blurred image has been set")
})
self.view.addSubview(backgroundImageView)

我收到以下错误,我不确定原因:

-[UIImageView setImageToBlur:blurRadius:completionBlock:]: unrecognized selector sent to instance 0x7ff08a802390
2015-01-27 10:50:44.326 TestApp[9289:66346] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView setImageToBlur:blurRadius:completionBlock:]: unrecognized selector sent to instance 0x7ff08a802390'

更新

看起来我不是唯一一个接收the error的人。

2 个答案:

答案 0 :(得分:0)

例外情况是我传递的图片是nil,反过来却违反了NSParameterAssert(image);

答案 1 :(得分:0)

var background = UIImage(named: "bg")

而不是尝试指定图像的完整路径。 它对我有用,我很确定它也适合你。

您也可以使用代码尝试此路径

var background = UIImage(named: "Images/bg");