Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QMUIButton在UITableView中遇到的布局问题 #439

Closed
fanyuecheng opened this issue Nov 22, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@fanyuecheng
Copy link

commented Nov 22, 2018

请填写运行环境

  • 设备:iPhone / iPad / 模拟器
  • 系统:iOS 12.1
  • Xcode 版本:10.1
  • QMUI iOS 版本:2.9.2

请描述具体问题

autolayout和frame布局均会出现。
QMUIKit/QMUIComponents/QMUIButton/QMUIButton.m文件:
当[cell.contentView addSubview:aQMUIButton];
sizeThatFits:中:
self.imageView.image 为空,而 self.currentImage 非空,导致布局计算错误。
可否改为:
CGSize imageSize = self.imageView.image ? [self.imageView sizeThatFits:CGSizeMax] : self.currentImage.size;

相关截图(断点的堆栈、控制台的 log)

2018-11-22 5 36 12

@MoLice MoLice added the bug label Nov 22, 2018

@targetkiller

This comment has been minimized.

Copy link
Collaborator

commented Nov 23, 2018

你好,请问可以打包这个 demo 到 contact@qmuiteam.com 吗?

@fanyuecheng

This comment has been minimized.

Copy link
Author

commented Nov 23, 2018

找到原因了,因为我在初始化button的时候使用到了button.imageView,比如更改了button.imageView.backgroundColor 或者 button.imageView.contentMode,此时将会出现这种问题,否则没有这种问题,demo很简单,截图里面基本代码都有了,只差cell中button的代码,随意初始化一个,更改其imageView的背景色即可,就不再发送了。

@targetkiller

This comment has been minimized.

Copy link
Collaborator

commented Nov 23, 2018

我这边按照你之前在另一处的截图和这里的截图的代码全部模拟了,发觉也不会有问题,哪怕改了 imageView 的各种属性。所以,可以麻烦你发一下代码到邮箱吗?

@fanyuecheng

This comment has been minimized.

Copy link
Author

commented Nov 26, 2018

邪门了 难道是我写代码的姿势不对吗==!
Demo已发送。

@MoLice

This comment has been minimized.

Copy link
Collaborator

commented Dec 21, 2018

该问题是系统自身问题,QMUIButton 已在 2.9.3 版本里修复该 bug。

@MoLice MoLice closed this Dec 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.