iOS SDK Release Notes for iOS 8.3 Beta 4 節選(UIKit)

來源:互聯網
上載者:User

標籤:ios

(沒有逐字逐詞翻譯,希望能夠理解,如果有不對的,懇請指正)

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



iOS SDK Release Notes for iOS 8.3 Beta 4 節選(UIKit)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.