UICustom按钮缩放错误

时间:2013-05-02 07:43:24

标签: ios objective-c interface-builder

在Interface Builder中

我构建了这个视图。 1是UIButtons

enter image description here

但在Iphone 6 Simulator上,它看起来像这样

enter image description here

我在水平滚动UIScrollView中将其中6个视图彼此相邻设置。

[self.slips setContentSize:CGSizeMake(1842.0f, 322.0f)];

self.slip1 = [[Slip alloc]initWithFrame:CGRectMake(0.0f, 0.0f, 307.0f, 322.0f)];
[self.slips addSubview:self.slip1];

self.slip2 = [[Slip alloc]initWithFrame:CGRectMake(307.0f, 0.0f, 307.0f, 322.0f)];
[self.slips addSubview:self.slip2];

self.slip3 = [[Slip alloc]initWithFrame:CGRectMake(614.0f, 0.0f, 307.0f, 322.0f)];
[self.slips addSubview:self.slip3];

self.slip4 = [[Slip alloc]initWithFrame:CGRectMake(921.0f, 0.0f, 307.0f, 322.0f)];
[self.slips addSubview:self.slip4];

self.slip5 = [[Slip alloc]initWithFrame:CGRectMake(1228.0f, 0.0f, 307.0f, 322.0f)];
[self.slips addSubview:self.slip5];

self.slip6 = [[Slip alloc]initWithFrame:CGRectMake(1535.0f, 0.0f, 307.0f, 322.0f)];
[self.slips addSubview:self.slip6];

其中slipsUIScrollView

slip1UIView的子类,并按此设置

- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
  if (self) {
    // Initialization code.
    //
    [[NSBundle mainBundle] loadNibNamed:@"LottoSlip" owner:self options:nil];
    [self addSubview:self.rootView];
  }
  return self;
}

有人可以帮助UIButtons错误排列的原因吗? 在此先感谢。

2 个答案:

答案 0 :(得分:0)

请转到硬件并检查设备并选择如上图所示..

enter image description here

答案 1 :(得分:0)

如果其他人有问题。我使用与自定义UIButtons大小完全相同的图像以及具有加倍大小和命名约定的图像版本来修复它。

imageName.png

imageName@2x.png

现在有效。