set image in UIImageview Programmatically
I have build one application. In this application I set image in UIImageView at the button's clicked action. and next time clicked on button the image is changed, this operation is successfully done. but after sometime the button is clicked properly but the image is not changed in UIIMageView and print following message on console:
ImageIO: CGImageRead_mapData 'o开发者_Python百科pen' failed '/Users/UserName/Library/Application Support/iPhone Simulator/4.2/Applications/02FE7A45-261F-4AED-AB37-592A228876FC/appName.app/imageName.png' error = 24 (Too many open files)
i can use following code for set the image in UIImageView
NSString *path = [[NSBundle mainBundle] pathForResource:strQue ofType:@"png"];
UIImage *img = [[UIImage alloc] initWithContentsOfFile:path];
[img1 setImage:img];
where img1 is the object of UIImageview and strQue is the name of the image
ImageIO: CGImageRead_mapData 'open' failed '/Users/UserName/Library/Application Support/iPhone Simulator/4.2/Applications/02FE7A45-261F-4AED-AB37-592A228876FC/appName.app/imageName.png' error = 24 (Too many open files)
This is just a wild stab in the dark here, but I'm guessing your app is opening too many files.
it seems that your path in variable strQue may be wrong..print log for that variable and check the path when it crashed....
one other possibility that if you have that three lines codes in for loop that may also cause this type of error...
精彩评论