susitha
susitha

Reputation: 467

How to resize an image for different orientations of iPad

IPad application coded for showing images. Images are showing in a UIImageView. Aplication should resize images according to the different oriention of the iPad. How to resize images for this purpose.

fullPhoto.fullImageBefore = [[[UIImageView alloc] initWithFrame:CGRectMake(40, 200, 350, 350)]autorelease];
NSString *image1 = fullPhoto.patient.imageBefore;
fullPhoto.fullImageBefore.image = [UIImage imageNamed:image1];
[fullPhoto.view addSubview:fullPhoto.fullImageBefore];
[image1 release];
[fullPhoto release];

Upvotes: 0

Views: 522

Answers (1)

Saurabh Passolia
Saurabh Passolia

Reputation: 8109

you should set the fullImageBefore.contentMode = UIViewContentModeScaleToFill;

fullImageBefore.autoresizingMask = UIViewAutoresizingFlexibleWidth| UIViewAutoresizingFlexibleRightMargin| UIViewAutoresizingFlexibleTopMargin| UIViewAutoresizingFlexibleHeight| UIViewAutoresizingFlexibleBottomMargin;

your viewController should implement:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

Upvotes: 2

Related Questions