Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0

前端 未结 10 1757
太阳男子
太阳男子 2020-11-28 00:21

I opened an existing iOS project with Xcode6 beta6, and Xcode lists the following warning for both Storyboard and Xib files:

Automatic Preferred Max L

10条回答
  •  情书的邮戳
    2020-11-28 00:44

    Now my Xcode version is 6.1. But I got this warning too. it annoys me a lot . after search again and again.I found the solution.

    Reason:You must have set your UILabel Lines > 1 in your Storyboard.

    Solution: set your UILabel Lines attribute to 1 in Storyboard. restart your Xcode. It works for me, hope it can help more people.

    If you really need to show your words more than 1 line. you should do it in the code.

    //the words will show in UILabel
    NSString *testString = @"Today I wanna set the line to multiple lines. bla bla ......  Today I wanna set the line to multiple lines. bla bla ......"
    [self.UserNameLabel setNumberOfLines:0];
    self.UserNameLabel.lineBreakMode = NSLineBreakByWordWrapping;
    UIFont *font = [UIFont systemFontOfSize:12];
    //Here I set the Label max width to 200, height to 60
    CGSize size = CGSizeMake(200, 60);
    CGRect labelRect = [testString boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName] context:nil];
    self.UserNameLabel.frame = CGRectMake(self.UserNameLabel.frame.origin.x, self.UserNameLabel.frame.origin.y, labelRect.size.width, labelRect.size.height);
    self.UserNameLabel.text = testString;
    

提交回复
热议问题