I am very new to objective c and I'm just getting my bearings. I want to do something really simple but it proves to be quite a challenge:
I am trying to display an image into an UIImageView
. The image I'm showing is large and I want it scaled down to fit the UIImageView
. I tried setting the AspectFit
View mode but the image gets displayed to the original size and is clipped by the UIImageView
. My code is below:
- (void)changeImages
{
UIImage* img11 = nil;
img11 = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"dog" ofType:@"jpeg"]];
u11.contentMode = UIViewContentModeScaleAspectFit;
u11.image = img11;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self changeImages];
}
Can anyone shed some light on this please?
Thanks!
NSLog(@"changeImages called")
to see if it is, or use a breakpoint. If it isn't, you may have forgotten to change the class of the ViewController in your nib/storyboard to the class of the code you wrote above. Isu11
specified as an IBOutlet and correctly linked up to the nib/storyboard? – Mercuriou11
? Maybe it's not the UIImageView that is clipping the image, but a parent view? – Lippoldu11
? Is itsautresizesSubviews
property set toYES
? – Ample