iOS learning note 25:uilabel An egg-ache problem

Source: Internet
Author: User
Problem description

In iOS8 versions below, NumberOfLines is set to 0, compile warning automatic Preferred Max Layout Width before iOS8.0, and cannot wrap.

Problem Analysis IOS8 The following version, to UILabel the number of rows is greater than 0, the single NumberOfLines is set to 0 is not possible, you also need to specify preferredMaxLayoutWidth,告诉 the location of the UILabel fold line. This problem does not exist in the iOS8, and does not need to be set preferredMaxLayoutWidth . Problem solving

If the Autolayout,uilabel width is adaptive, indeterminate, use the following code settings:

1 -(void) layoutsubviews2{3    [Super Layoutsubviews] ; 4     Self.label.preferredMaxLayoutWidth = self.label.bounds.size.width; 5 }

If it is a fixed width, it can be set directly.

iOS learning note 25:uilabel An egg-ache problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.