【发布时间】:2015-05-28 14:23:47
【问题描述】:
情况如下:我有一个 VC,里面有一个自定义 UIView。此自定义 UIView 有一个 .xib 文件,其中包含 2 个 UIImageView。我试图通过使用 AutoLayout 让这 2 个 UIImageViews 在不同的屏幕尺寸上缩放到相同的尺寸。但是,当我启动我的应用程序时,我的自定义 UIView 中的图像超出了自定义 UIView 的超级视图(即 VC)容器大小的范围。请帮忙。这里有一些图片可以更详细地解释这个问题。
我在自定义 UIView 中的代码: @implementation CustomTwoImagesSelectedUIView
-(id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self load];
}
return self;
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self load];
}
return self;
}
- (void)load {
[[NSBundle mainBundle] loadNibNamed:@"CustomTwoImagesSelectedUIView" owner:self options:nil];
self.lastImageView.layer.cornerRadius = 5.0f;
self.lastImageView.clipsToBounds = YES;
self.secondToLastImageView.layer.cornerRadius = 5.0f;
self.secondToLastImageView.clipsToBounds = YES;
[self addSubview:self.twoImagesSelectedView];
}
【问题讨论】:
标签: ios objective-c uiview autolayout