What do you know about the 66 knowledge points that an iOS developer has to master?

Source: Internet
Author: User
Tags stack pop
1. Non-variable group converted to variable array
Declaring an array of instance variables must remember to implement the

If you still need to find the object after traversing the array, remember to end the search (return/break) nsarray * arr = @[@ "People in the Way", @ "pancake man", @ "Journey to the Westward",];

Nsmutablearray * arr = [Nsmutablearray Arraywitharray:arr]; When fetching data in an array, you need to convert an object in an array to a numeric class by using a suffix
P11. Age = [newarr[1] intvalue];



2. Get string length
NSString * str = namelabel. Text;
Cgsize size = [str sizewithattributes: @{nsfontattributename: [Uifont systemfontofsize:17]}];
You can now get size. Width (the width of the string is the string length)



3. Hide the navigation bar of the view controller on a separate view

-(void) Viewdidappear: (BOOL) animated{
    [Super viewdidappear:animated = NO];
    [Self. Navigationcontroller setnavigationbarhidden:yes];
}



4. The side Hat method (stretching the picture) will be a pixel point continuously copy other pixel dot invariant stretching will not be a picture distortion

The first
    [[Uiimageview alloc] Init].image = [[UIImage imagenamed:@ ' bubble.png '] stretchableimagewithleftcapwidth:20 TOPCAPHEIGHT:20];
    The second type of
    uiimage * image =[uiimage imagenamed:@ "7.jpg"];
    [Image resizableimagewithcapinsets:uiedgeinsetsmake (0, image.size.width, 0, 0)];
    [[Uiimageview alloc] init].image = image;



5. Monitoring system to send notifications
Listen for notification of changes to the keyboard frame and get the object from the keyboard's properties [[Nsnotificationcenter defaultcenter]addobserver:self selector: @selector (Keyboar
    
    Dwillchangeframe:) name:uikeyboardwillchangeframenotification Object:nil]; -(void) Keyboardwillchangeframe: (nsnotification *) Noti {//Uikeyboardanimationcurveuserinfokey = 7;//UIK
Eyboardanimationdurationuserinfokey = "0.25";
Uikeyboardboundsuserinfokey = "Nsrect: {{0, 0}, {320, 216}}";
Uikeyboardcenterbeginuserinfokey = "Nspoint: {160, 588}";
Uikeyboardcenterenduserinfokey = "Nspoint: {160, 372}";
Uikeyboardframebeginuserinfokey = "Nsrect: {{0, 480}, {320, 216}}";
uikeyboardframechangedbyuserinteraction = 0;
        
        Uikeyboardframeenduserinfokey = "Nsrect: {{0, 264}, {320, 216}}";
        
        Once the keyboard changes, the coordinates of the _inputview and _tableview are changed//the object is obtained through the dictionary nsdictionary * dic = Noti. UserInfo; Get the animation when the long float = [[dic Objectforkey:uikeyboardaniMationdurationuserinfokey] Floatvalue];
        
        Gets the animation rate int curve = [[dic Objectforkey:uikeyboardanimationcurveuserinfokey] intvalue];
    Get keyboard coordinates cgrect rect = [[dic Objectforkey:uikeyboardframeenduserinfokey] cgrectvalue]; }



6. Draw a rectangle through a string maxfloat infinity
NSString * str = _chatarr[indexpath. row];
CGRect rect = [str  boundingrectwithsize:cgsizemake (maxfloat) options:nsstringdrawinguseslinefragmentorigin | Nsstringdrawingusesfontleading attributes:@{nsfontattributename: [Uifont systemfontofsize:15]} Context:nil];


7. View level switching
Key points:
[Self. window exchangesubviewatindex:0 withsubviewatindex:1];
1. If the parent view is not interactive, then the child view placed above it is not interactive
2. If the parent view can interact then the interactivity of the child view placed above it is up to you
Key words: userinteractionenabled
Image. userinteractionenabled = YES;



8. Binary Data Transformation Type

string into binary data

NSString * str = @ "Girls"; NSData * data = [str datausingencoding:nsutf8stringencoding];

Binary data converted to string NSString * str2 =[[nsstring alloc]initwithdata:data1 encoding:nsutf8stringencoding];

Turn a picture into binary data

1. Need to get picture path

NSString * Imageviewpath =[[nsbundle mainbundle]pathforresource:@ "a" oftype:@ "jpg"];

NSData * data = [[NSData Alloc]initwithcontentsoffile:imageviewpath];

2. Directly convert the images added to the project into binary data types

UIImage * image = [UIImage imagenamed:@ "20.jpg"]; NSData * data = uiimagejpegrepresentation (image, 1);

Turn the image into binary data back to the picture

Method 1 can directly call out the picture from the path

UIImage * image = [UIImage Imagewithcontentsoffile:datapath];

Method 2: First remove the binary data from the path and convert the Imagewithdata property to the picture type

NSData * data = [NSData datawithcontentsoffile:[self getfilepath:@ "Data.plist"]]; UIImage * Image =[uiimage Imagewithdata:data];



9. How to delete all child views on a view all code :

Get all the child views stored on the View traversal array find all objects find views

for (UIView * v in self.view.subviews) {
    [v Removefromsuperview];
}



10. Put a view at the front
[Self. View Bringsubviewtofront:_tableview];



11. Page jump (need to find window)
Find window
Method 1:

UIWindow * window =[[[uiapplication Sharedapplication]delegate]window];
window. Rootviewcontroller = Aviewcontroller;

Method 2:

UIApplication * app = [uiapplication sharedapplication];
Appdelegate * delegate = app. Delegate;
UIWindow * window = delegate. window;
window. Rootviewcontroller = Aviewcontroller;



1. Page Flip

[UIView Beginanimations:nil Context:nil];
[UIView Setanimationduration:1];
[UIView Setanimationtransition:uiviewanimationtransitioncurlup Forview:window Cache:yes];
[UIView commitanimations];

2. Modal eject (present show dismiss disappears)

3. Navigation controller (push pressure stack pop out stack)//control view switch through navigation Controller

1. Return to the previous interface: [Self. Navigationcontroller popviewcontrolleranimated:

Related Article

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.