2

我正在呈现一个模式视图,其中 UIImageView 设置为内容模式填充比例(通过 xib)。我在模态视图类中使用父类的缩略图设置 UIImage :

NSURL * finishedMovie = [self applicationDocumentsDirectory:@"FinishedVideo.mov"];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:finishedMovie];
UIImage *thumbnail = [player thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];

previewScreen = [[PreviewScreenViewController alloc]initWithNibName:@"PreviewScreenViewController" bundle:nil];
previewScreen.thumbnailImage = thumbnail;
[self presentModalViewController:previewScreen animated:YES];

然后在模态视图类本身:

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
previewImageBox.image = thumbnailImage;

}

问题是,当视图出现时,它似乎忽略了 xib 中设置的内容模式,只是以全尺寸插入图像。

这似乎是一个错误,因为当我返回此视图时,图像正确适合 UIImage 视图。

任何人都可以帮忙吗?

谢谢。

4

2 回答 2

1

好的解决了!如果您在代码中手动创建 UIImageView,它似乎可以工作。

// Do any additional setup after loading the view from its nib.
//Work around to solve bug in UIToolkit where aspect ratio is ignored when view loads.
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(13, 87, 294, 164)];
//Set the image to our thumbnail.
[self.view addSubview:imageView];
于 2012-04-30T15:24:06.840 回答
0

您很可能将clipsToBounds属性设置为NO. 这将防止UIImageView剪切其矩形之外的内容。您可以设置图层borderColorUIImageView,看看这是否真的发生了。

于 2012-05-06T00:10:53.387 回答