"We all love Paul Hegarty" Stanford IOS8 Public Lesson Personal Note 22 multi-MVC mode AutoLayout automatic layout in demo

Source: Internet
Author: User

In the last word, we introduced the multi-MVC pattern and the Segue transition in detail, which is explained by a new demo.


We are building a new psychologist project. Change the name of Viewcontroller to Psychologistviewcontroller. So what does this controller do? The system asks you a question, and then you answer, the system will determine whether you are happy according to your answer, so that you can use our previous Hppiness project.

Add a label to the view, then adjust the font to 36, the text centered, and the top side of the label aligned with the Blue Line.


Every word will penetrate some of the automatic layout content. We have this label reset to its recommended location.


We will see:


The Blue line in the middle indicates that the label is associated with the bottom boundary, but we don't want to do this because you don't confirm the size of the device you're running. Usually we do not associate the next boundary, but let the distance of the lower boundary be a flexible variable.

We open the dimension detector on the right, and we can see all the constraints:


I can select a constraint I don't like and delete it. The yellow line will appear after the deletion, because we do not have enough constraints, as we have said before, in trying to update frame, you will see the yellow line disappears.

With the problem, now we drag the answer out, this is a button. I drag this button to the middle, then click Reset Location to the recommended location (as in the above), then we delete the unnecessary constraints, here I only keep the vertical center, we do not need the upper and lower spacing and fixed width height, because I want the size of this button according to its contents to automatically adjust.


At this point I need to use the other constraints, click on the bottom right button bar of the first button


Because the center is in the vertical direction, just add a horizontal orientation.


You will see now that our buttons are centered in both horizontal and vertical directions. Update frame again, the position of the button is adjusted well.


Then copy the button and add a different content.

The New button resets to the recommended location and you will see that it has two constraints, a horizontal center, and a bottom distance:



We create a third button in the same way:


Let's Run our program:


You can see that the top text is cut off and rotated:


It looks good in the horizontal screen mode, but the vertical screen is not going to work. Since we have set the font size to 36th, you can see it in the autoshrink of the storyboard property monitor, the current setting is fixed

Font size (fixed font size):


But this font does not need a fixed size, I need to set its minimum value, do not want it to be smaller than 12th, set the following:


Now let's run it again and you'll see that the font is automatically scaled and the font gets bigger when the screen becomes wider.


So is there any way to make text wrap? One way is to replace the label with TextView. Another way is to set the line Breaks in the label, the current practice is to delete the tail, the most direct set the value of lines directly.



"We all love Paul Hegarty" Stanford IOS8 Public Lesson Personal Note 22 multi-MVC mode AutoLayout automatic layout in demo

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.