I’ve been looking for hours now and i cant find a solution. i have an imageview, i have declare it as an IBOutlet, inside that imageview i have already put an image using the interface build of xCode 4.2.
Now my quesion, whats the line of code that it can change the image of the imageview?
The old ones like UIImage *image = [UIImageView imageNamed:@"image2.png"];
its not working because it says that *image is unused variable. it also gives me error at imageNamed it says No known class method for selector ‘imageName’
Whats the new code in 4.2? or is it me doing something wrong?
That should do it. UIImageView has an
imageproperty that you can set, either as above, or using the-setImage:method that the property provides. Also, from the docs:Your other questions:
In the code you provided, you’re assigning the image to a local variable. If you don’t then do something with that variable, there’s no point in that code. Instead, assign the image to the
imageproperty of your image view, as described above.That just looks like a typo in your code. The lack of a ‘d’ in ‘imageName’ is surely the problem.
Nothing has changed with respect to setting the image of an image view, as far as I know. I think you’ve just got a couple little issues in your code.