I have problems with the ScaletoFit method. I Have a UIPageViewController with a UIImagesView and want to show different pictures in it, but it does not work as it should.
With these two lines I initialize the picture.
self.screenPicture.image = [UIImage imageNamed:@"1.png"];
self.screenPicture.contentMode = UIViewContentModeScaleAspectFit;
it's build in a case structure, which decides what picture the user can see.
switch(self.index)
{
case zero: {
self.screenNumber.text = [NSString stringWithFormat:@"1.", nil];
self.screenPicture.image = [UIImage imageNamed:@"1.png"];
self.screenPicture.contentMode = UIViewContentModeScaleAspectFit;
NSLog(@"%d",self.index);
break;
}
case one: {
self.screenNumber.text = [NSString stringWithFormat:@"2.", nil];
self.screenPicture.image = [UIImage imageNamed:@"2.png"];
self.screenPicture.contentMode = UIViewContentModeScaleAspectFit;
NSLog(@"%d",self.index);
break;
}
case two: {
self.screenNumber.text = [NSString stringWithFormat:@"3.", nil];
self.screenPicture.image = [UIImage imageNamed:@"3.png"];
self.screenPicture.contentMode = UIViewContentModeScaleAspectFit;
NSLog(@"%d",self.index);
break;
}
case three: {
self.screenNumber.text = [NSString stringWithFormat:@"4.", nil];
self.screenPicture.image = [UIImage imageNamed:@"4.png"];
self.screenPicture.contentMode = UIViewContentModeScaleAspectFit;
NSLog(@"%d",self.index);
break;
}
default: {
self.screenNumber.text = [NSString stringWithFormat:@"5.", nil];
self.screenPicture.image = [UIImage imageNamed:@"5.png"];
self.screenPicture.contentMode = UIViewContentModeScaleAspectFit;
NSLog(@"%d",self.index);
break;
}
}
In the App the picture is now in the original size, which is too big.
Why is the ScaleAspectFit
-Method not working?
can somebody help me?
Thanks:)