iOS development note 7:text, UI interaction details, two animation effects, and more

Source: Internet
Author: User

Text mainly summarizes Uilabel, Uitextfield, Uitextview, Uimenucontroller and Uiwebview/wkwebview related issues.

The UI details mainly summarize some of the details of the interface interaction development, including the masonry part of the problem.

Animation describes the recent use of the two, is a common level, animation this part will be devoted to the summary under study.

Finally, two tools and three Xcode usage settings are introduced.

1.Text (1) Uilabel display multiple lines of text and display text on top

Do not limit the height of the Uilabel (width needs to be set, determine when the text wraps), NumberOfLines set to 0 (set to 0 for unlimited number of rows).

(2) Usensmutableattributedstring to meet individual display requirements

For example, the text line spacing requirements, a line of text a few text size, color has special requirements, etc., can be set by nsmutableattributedstring.

(3) Text wrapping mode

Set Linebreakmode, for example, to break the line by word to line nslinebreakbywordwrapping, the end of the nslinebreakbytruncatingtail, such as ellipsis.

(4) TextField'sClearbuttonmode,PlaceholdeR,Keyboardtype,tintcolor,tag,securetextentry Typical application scenarios

Clearbuttonmode, set a key to clear the button display mode, usually in the editing state to display the button

placeholder/Attributedplaceholder, set placeholder text, if the style has special requirements, such as color, you can set the Attributedplaceholder.

Keyboardtype, when the initial entry into the editing state, the default display of the keyboard type, such as enter the phone number of the place, using the numeric keypad Uikeyboardtypenumberpad can, but the actual use of the discovery, If you install a third-party input method such as Sogou input method, the settings Uikeyboardtypenumberpad does not work, the keyboard is still displayed as other types, set to Uikeyboardtypephonepad to take effect, The difference is that Uikeyboardtypephonepad is also allowed to enter *, #, relative to Uikeyboardtypenumberpad, but the basic style is the same.

To set the keyboard type after Uikeyboardtypephonepad

Tintcolor, such as the TextField in the editing state of the cursor color requirements, set this property can be.

tag, for a page containing multiple textfield, often need to be in the proxy method to separate processing, using the tag attribute can be identified, TextView, etc. is also through the tag to distinguish

Securetextentry, set the input character of the light and dark text display, set to Yes input characters when displayed as *, general password input used, but need to be aware of, for the system native TextField, if added a shader switch button, By controlling this property to toggle the display mode, there are some problems, one is to toggle the text state to the dark state (Securetextentry = YES), the input character before the string will be the case, but the text state, the end of the editing state after entering the editing state, if you click the Delete button, All characters that have been entered are emptied. If you want to switch status after the input does not empty, again into the edit state click the Delete button to delete only the previous character, you need to rewrite the TextField for this property.

(5) TextField limit input words

TextField Unlike TextView, there is no Didchange event method in the proxy method, but the same effect can be achieved by listening uicontroleventeditingchanged, entering the limit input word Count

(6) TextView Change the return key type and automatically determine the availability of the keys according to the input situation

Set two properties to

(7) TextView How to respond to events that press the Send button

In Proxy method Shouldchangetextinrange, you can---- if ([Text isequaltostring:@ "\ n"]) {...}

(8) TextView realization of placeholder effect in TextField

TextView itself does not have this property, the implementation method is to add a UILabel on the TextView as placeholder, in the proxy method to control the display of the label, it is important to note that the UILabel

If you add directly to the TextView , the subsequent adjustment of the layout on the IOS7 device will crash, it is recommended to add TextView on a uiview, and then add Uilabel on this view to control.

(9) TextView Dynamic change according to the input content

When writing a comment, if the number of words, then the height of the TextView should be increased with the increase in content, of course, there must be a high limit, not unlimited growth.

You can dynamically adjust the height when you enter characters in TextView, and the following methods can be tested at IOS7, 8, and 9

There is also a need to be aware that when you re-enter the editing state and have the last input draft, the TextView cursor should generally appear at the end of the last word

(10) using regular expressions to verify the validity of mobile phone number input

One is to determine whether the first number is 1, the second is based on the current situation to determine the validity of the next digit, and the third is to verify whether the following 9 characters is a number

(11) Custom long Press eject after Uimenucontroller

(UIWebView)

Pay attention to three points, one is to notice in the proxy method set the top status bar in the circle, that is [uiapplication sharedapplication]. Networkactivityindicatorvisible

Second, we need to do some processing in the Willdisappear

Third, loadrequest. Note Ignore caching, otherwise the page may not be up-to-date

(Wkwebview)

Using the same engine as Safari, iOS8 and above recommend using Wkwebview instead of UIWebView, which is much more useful than uiwebview loading and supports the progress bar display.    

2.UI Interactive Details(1) dynamically calculate height based on cell display content

It is important to note that when you use the masonry layout cell, you must not ignore the bottom attribute, because the height is calculated based on the size of the content, and it is certain that the distance from the top to the bottom is determined by the contents of the cell, that is, the height of the cell.

(2) Update layout with masonry

If you use the mas_updateconstraints method to update a layout property that has already been set, use mas_remakeconstraints to clear the original layout settings and re-layout.

(3) Click the blank area to close the bullet box

The click Area is judged, and when the click Area is outside the range of the frame, the close action can be

(4) View level management

Three most commonly used, one is to move the view to the top

The second is to move the view to the lower level

The third is to load the view onto the window

(5) When using Uiimageview to do background view, pay attention to openinguserinteractionenabled Property

The default Userinteractionenabled property is no, it needs to be turned on, otherwise the Click event will not respond when added to the UIButton above

(6) UIButton Click Regional Settings

For example, a small icon needs to support the click, need to pay attention to increase the UIButton response area, consider the user's click Experience.

(7) Sdwebimage loading progress bar display

Sdwebimage has encapsulated methods to support monitoring of loading progress

(8) Note close the Userinteractionenabled property of Uipagecontrol

Pay attention to closing the Userinteractionenabled property when using the Carousel, otherwise click the Pagecontrol area and the dot index will change.

(9) Album Processing,Phphotolibrary replaces alassetslibrary

IOS8 above must be used phphotolibrary.

(10) stretch a picture with code

3. Two animations(1) Load wait circles

Animate a picture by selecting a row of gradients to load a spinning picture

(2) Cashapelayer + uibezierpath implement gradient button

Use Uibezierpath to draw a rectangle, the control point is added in the middle, and note that the last point to be closed, depending on the distance of the slide, the X coordinate of the control point will change with the movement

The effect is as follows

4. Other (1) DSYM

After the app uses friends League stats to find problems based on the error crash information, you can use the tool "DSYM" to track processing.

(2) Network Link Conditioner

You can download the tool on your Mac to simulate the network environment for testing, and on the real machine you can find these tools by using the developer options in the settings.

(3) empty black area on top and bottom of app after launch

Because the set start diagram is loaded as launchimage, but does not cause the picture, the system will determine the display size according to the launchimage size, add launchimage after the normal display

(4) After Xcode upgrade, third-party plugins cannot be used

Get Xcode uuid, add to the plug-in corresponding project, re-run again to normal use.

Get the UUID of Xcode: "Defaults read/applications/xcode.app/contents/info dvtplugincompatibilityuuid"

(5) Use code blocks to improve efficiency

For frequently repeated input of some code, such as some proxy methods, layout code, such as the use of code blocks for management can improve efficiency, for the variables, in the set code block, < #变量名称 #> Such a format, the next time, the compiler will be able to identify the need to enter values here.

5. Reference

(1)Text Programming Guide for IOS

(2)assetslibrary framework broken on IOS 8

(3)Network Link Conditioner

(4)XCODE7 real-Machine debugging problems

(5)iOS development details Jiu Zheng expression

(6) Verify the mailbox and phone number with regular expressions

(7)Understanding and analyzing IOS application Crash Reports

(8)Xcode plugin info.plist/dvtplugincompatibilityuuids

(9)DSYM file Analysis tool

() presumptuous use of Uibezierpath and cashapelayer to draw a variety of graphics

iOS development note 7:text, UI interaction details, two animation effects, and more

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.