UIImage initWithContentsOfFile doesn't work
I have question: I want to avoid [UIImage imageNamed:].
So i did:
UIImage *prodImg = [[UIImage alloc] initWithContentsOfFile:@"myimage.png"]; controller.productImg.image = prodImg; [prodImg release];
But now the image is not shown anymore.
Does anyone know how to get that to work?
Solutions Collect From Internet About “UIImage initWithContentsOfFile doesn't work”
The above code is not working because correct way to do it is-
NSString *thePath = [[NSBundle mainBundle] pathForResource:@"default" ofType:@"jpeg"]; UIImage *prodImg = [UIImage imageWithContentsOfFile:thePath]; controller.productImg.image = prodImg; [prodImg release];
- How do I temporary disable warnings in my objective c source file?
- NSUserDefaultsDidChangeNotification not sent when app resumes from the background
- iOS reading from a file
- Distribute ipa to client
- Casting sender to IBAction as id or specific class
- how to set attributes in NSAttributedString in iOS?
- How can I convert Int32 to Int in Swift?
- iOS simulator scaled bug
- How to fire method only once when using panright with Hammer.js?
- Why does the following protocol have this required function?
- How to provide a localized description with an Error type in Swift?
- changing AFNetworking baseURL
- How to change the text position inside UITextView
- When is the autorelease pool triggered
- Xcode 7 Unable to determine compiler to use