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

最佳答案

您应该设置fullImageBefore.contentMode = UIViewContentModeScaleToFill;

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


您的viewController应该实现:

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

10-08 18:42