如何调整iPad的不同方向的图像大小

时间:2012-01-03 11:34:30

标签: ios xcode ipad uiimageview orientation

用于显示图像的IPad应用程序。图像显示在UIImageView中。应用程序应根据iPad的不同方式调整图像大小。如何为此目的调整图像大小。

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];

1 个答案:

答案 0 :(得分:2)

您应该设置fullImageBefore.contentMode = UIViewContentModeScaleToFill;

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

你的viewController应该实现:

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