【发布时间】:2015-10-04 11:35:25
【问题描述】:
我正在努力启用使用UIScrollView 放大UIPopoverController。 scrollView 是 600x600,它应该显示一个显示UIImageView 的视图控制器。图像显示,但未居中。
这是弹出窗口中显示的视图控制器中viewDidLoad 方法的代码。
- (void)viewDidLoad {
self.imageView = [[UIImageView alloc] init];
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
self.imageView.image = self.image;
self.scrollView = [[UIScrollView alloc] init];
self.scrollView.backgroundColor = [UIColor greenColor];
[self.scrollView setContentSize:self.imageView.image.size];
[self.scrollView setDelegate:self];
[self.imageView setFrame:CGRectMake(0, 0, 600, 600)];
self.view = self.scrollView;
[self.scrollView addSubview:self.imageView];
// Do any additional setup after loading the view.
}
UIScrollView 和 UIImageView 在弹出窗口中显示的 UIViewController 内声明为属性。 image 是另一个属性,在创建 UIViewController 时设置为指向图像。
这就是它的样子。
我想将图像置于弹出框的中心并使其适合。我怎样才能做到这一点?谢谢。
【问题讨论】:
标签: ios uiscrollview uiimageview