Issues and solutions for iOS writing projects (2)

Source: Internet
Author: User

11. Adaptive Text Height

1 nsdictionary *attributes = @{nsfontattributename: [uifont systemfontofsize:]}; 2 3 CGRect rect = [Text Boundingrectwithsize:cgsizemake (Viewwidth, maxfloat) options: Nsstringdrawinguseslinefragmentorigin attributes:attributes  Context:nil]; 4 5 return rect.size.height;

IOS9 Adaptation Settings

In fact, in Xcode 7, when we create a new iOS program, the Bitcode option is set to Yes by default. We can see this setting in the "Build Settings", "Enable bitcode" option.

Either let the third-party library support or turn off the target's bitcode option.

IOS9 HTTPS to HTTP

1 <key>NSAppTransportSecurity</key> 2  3     <dict> 4  5          <!--Connect to anything ( This was probably bad)-- 6  7         < Key>nsallowsarbitraryloads</key> 8  9         <true/>  One     </dict>

14. Intercepting strings

[Str substringfromindex:6];

Substringwithrange:nsmakerange (4,2) intercepts a portion of a string, starting with the 4th bit, intercepting two-bit

substringtoindex:n Intercept to the first few

The (substringfromindex:n) string is intercepted from the nth bit until the last

16.nsscanner:nil string argument

The reason for the error is that when we call a method, we pass in an empty string (note that the string content is empty) as a method parameter.

I get a string of data from the server, considering that some objects do not contain this string variable, I use the first to determine whether the string is empty, for example:

Suppose that this string is called STR,

First determine if (Str!=nil) {

Do something

Double Data=[str Doublevalue];

}

However, when the data is empty, the error is still

The official Apple document has such a code:

    1. ID avalue = [arraywithnull objectatindex:0];
    2. if (Avalue = = nil) {
    3. NSLog (@ "equals nil");
    4. } else if (avalue = = [NSNull null]) {
    5. NSLog (@ "equals NSNull instance");
    6. if ([Avalue Isequal:nil]) {
    7. NSLog (@ "Isequal:nil");
    8. }
    9. }
    10. Output: "Equals NSNull instance"

Although finally my problem solved, I in the If Judgment with

    1. if (![ Tmpnewsmodel.latitude isequal:[nsnull Null]]) {
    2. Do something
    3. }

The problem is solved, but not quite understand the difference between nil and nsnull?

17.iphone size


18. Modify the Mac host file

sudo nano/etc/hosts

The same is the input password, open the Hosts file, according to your needs to edit the file, after editing, press Ctrl+o Save,

When the File Name to Write:/etc/hosts, press ENTER to confirm, and then press Ctrl+x to exit.

IOS8 set TableView Separatorinset Split line start from the top of the border

The following methods have been tested to work correctly on iOS7 8

1-(void) Viewdidlayoutsubviews2 3 {4 5     if([Self.tableview respondstoselector: @selector (setseparatorinset:)]) {6 7[Self.tableview Setseparatorinset:uiedgeinsetsmake (0,0,0,0)];8 9     }Ten  One      A  -     if([Self.tableview respondstoselector: @selector (setlayoutmargins:)]) { -  the[Self.tableview Setlayoutmargins:uiedgeinsetsmake (0,0,0,0)]; -  -     } -  + } -  +   A  at-(void) TableView: (UITableView *) TableView Willdisplaycell: (UITableViewCell *) cell Forrowatindexpath: (Nsindexpath *) Indexpath -  - { -  -     if([Cell Respondstoselector: @selector (setseparatorinset:)]) { -  in [Cell Setseparatorinset:uiedgeinsetszero]; -  to     } +  -      the  *     if([Cell Respondstoselector: @selector (setlayoutmargins:)]) { $ Panax Notoginseng [Cell Setlayoutmargins:uiedgeinsetszero]; -  the     } +  A}

20.url can not have Chinese characters, need to convert no will request error

Issues and solutions for iOS writing projects (2)

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.