Knowledge Point (i)

Source: Internet
Author: User

1. Apple recommended single-use method: If there is a user class, create a class method in the user class
+ (User *) shareinstance
{
static User *user = nil;

Static dispatch_once_t oncetoken;//Ensure that the following block code is called only once

Dispatch_once (&oncetoken, ^{

user = [[user alloc] init];

});

return user;
}
When creating a singleton in the program later: user* user = [user shareinstance];

2. When using Uitextfield to enter a password, it is best to use Textfield.securetextentry = YES to hide the display of the password.

Functions that automatically calculate the height of text after 3.ios7: [String Boundingrectwithsize:cgsizemake (Weigth, heigth) options: Nsstringdrawinguseslinefragmentorigin attributes:attrdict Context:nil];
String is the contents of the text, and the function return value is CGRect type

The first parameter: Set the width and height of the text, in fact, it is only necessary to pay attention to the width of the setting, the height of the value of the text as much as the content of the automatic adjustment, the general initial value set a larger value.

Second parameter: How the text is displayed (above is the way of wrapping)

The third parameter: A dictionary of text size and color properties, such as:
Nsdictionary *attrdict =
@{nsfontattributename:[uifont Systemfontofsize:20.0f],nsforegroundcolorattributename:[uicolor BlueColor]};

Fourth parameter: Context (Nil can be passed)

Knowledge Point (i)

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.