iOS SDK Release Notes for iOS 8.3 Beta 4 节选(UIKit)

(没有逐字逐词翻译,希望能够理解,如果有不对的,恳请指正)

UIKit


Note
注意

When linking against iOS 8.3, any code that relies on layout information (such as the frame) of a UIButton subview when the button is not in the window hierarchy will need to send layoutIfNeeded to the button before retrieving layout information (such as button.titleLabel.frame) to ensure that the layout values are up to date.

在iOS8.3下编译链接的时候,如果UIButton(包括子类)不是窗口级别的控件,任何涉及获取和操作UIButton(包括子类)布局信息的代码,都应该先发送一个layoutIfNeeded事件(其实就是执行UIButton的layoutIfNeed方法),以确保获取到的UIButton的布局信息是最新的。

For example, if you had something like this:

举例如下,如果iOS8.3以前,你这样写代码:

UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
// code that sets up the button, but doesn’t yet add it to a window
CGRect titleFrame = button.titleLabel.frame;
// code that relies on the correct value for titleFrame

You now need:
那么,现在你需要这样写代码:
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
// code that sets up the button, but doesn’t yet add it to a window
[button layoutIfNeeded]; // This is also safe pre-iOS 8.3
CGRect titleFrame = button.titleLabel.frame;
// code that relies on the correct value for titleFrame



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值