ios xib 四等分_iOS autolayout tableviewcell 实现三等分 设置宽高比为1:1,程序运行时说约束有错误...

需求如下:

本人最近在做毕业设计,音乐app,现在遇到问题,想做一个自适应宽度的tableviewcell,里面有三个imageView,imageView的宽度根据屏幕大小自适应,实现imageView的三等分,即imageView宽度自适应,但是imageView的高度要跟宽度是一样高的,即宽高比为1:1。(注明:我的测试图片为宽高比为2:1)。

程序运行如图

确实是实现了我的需求,但是运行的时候控制台会出现很多很多的说我的约束出现错误。

先上一下我设置的约束,这是我的xib图片

好了,现在一个一个看约束,第一个imageView的约束

第二个imageView的约束

第三个imageView的约束

我大概知道最关键的一部分错在哪里,就是我给每个imageView都加了一个约束就是 aspect ratio = 1:1,如果去掉这个约束的话程序运行时控制台是不会说约束错误的,但是去掉了这个约束的话又不是我想要的结果。

下面是控制台的输出

Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)

(

"<0x7faa62826ba0 uiimageview:0x7faa62826d80.width="=" uiimageview:0x7faa62826d80.height>",0x7faa62826ba0>

"<0x7faa62827510 uiimageview:0x7faa60734960.width="=" uiimageview:0x7faa628267c0.width>",0x7faa62827510>

"<0x7faa62827560 uiimageview:0x7faa60734960.leading="=" uitableviewcellcontentview:0x7faa607347f0.leadingmargin>",0x7faa62827560>

"<0x7faa62827650 uiimageview:0x7faa628267c0.width="=" uiimageview:0x7faa62826d80.width>",0x7faa62827650>

"<0x7faa628276a0 h:>",0x7faa628276a0>

"<0x7faa62827790 uiimageview:0x7faa62826d80.top="=" uitableviewcellcontentview:0x7faa607347f0.topmargin>",0x7faa62827790>

"<0x7faa628277e0 h:>",0x7faa628277e0>

"<0x7faa62827880 uitableviewcellcontentview:0x7faa607347f0.trailingmargin="=" uiimageview:0x7faa62826d80.trailing>",0x7faa62827880>

"<0x7faa62827830 uitableviewcellcontentview:0x7faa607347f0.bottommargin="=" uiimageview:0x7faa62826d80.bottom>",0x7faa62827830>

"<0x7faa6282b8f0 v:>",0x7faa6282b8f0>

"<0x7faa6282ca60 h:>"0x7faa6282ca60>

)

Will attempt to recover by breaking constraint

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.

The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值