iOS Client Coding Project record (i)

Source: Internet
Author: User

1:uitextfield Settings appear clear button

Self.textField.clearButtonMode == yes when Uitextfield is not empty, [Uitextfield Resignfirstresponder] Close the keyboard

2: Painting an underline

With A view that defines its location and background, the code below is for reference         only = Nil;          = [Uicolor clearcolor];         UIView43.5, kscreen_width-20.5)];         = [Uicolor colorwithhexstring:@ "0xaebdc9"];        [Self.contentview Addsubview:_lineview];

3: Table Some settings

Self.myTableView.separatorStyle = Uitableviewcellseparatorstylenone;//do not add line breaksSelf.myTableView.backgroundColor = [Uicolor colorwithhexstring:@"0xfafafa"]; UIView*upbgview =[[UIView alloc] initWithFrame:self.view.bounds]; Upbgview.backgroundcolor=[uicolor colorwithhexstring:@"0x29333f"]; [Upbgview sety:-cgrectgetheight (upbgview.bounds)];        [Self.mytableview Addsubview:upbgview]; Self.myTableView.contentInset= Uiedgeinsetsmake (-khigher_ios_6_1_dis ( -),0,0,0);//Indent inSelf.mytableview.tablefooterview=[self Customfooterview];//method to return to view, see 5thSelf.myTableView.tableHeaderView =[self customheaderview]; Extension: Uitableviewcellselectionstyle Select the style of the row uitableviewcellselectionstylenone, Uitableviewcellselectionstyleblue,uitableviewcellselectionstylegray If you want to customize the background color of the cell Cell.selectedbackgroundview =[[[ UIView alloc] Initwithframe:cell.frame]];cell.selectedbackgroundview.backgroundcolor=[Uicolor Redcolor]; change line line Color Tableview.separatorcolor= [Uicolor Bluecolor];

4: You can define the header and bottom view (code on top)

-(UIView *) customheaderview{UIView*headerv = [[UIView alloc] Initwithframe:cgrectmake (0,0, Kscreen_width, the)]; Uiimageview*loginlogo = [[Uiimageview alloc] initwithimage:[uiimage imagenamed:@"Login_logo"]]; CGFloat loginlogoheight= Cgrectgetheight (loginlogo.bounds) *kscreen_width/cgrectgetwidth (loginlogo.bounds); if(Loginlogoheight > the) {[Headerv setheight:loginlogoheight]; } loginlogo.frame= CGRectMake (0,0, Kscreen_width, loginlogoheight);    [Headerv Addsubview:loginlogo]; returnHeaderv;}-(UIView *) customfooterview{UIView*footerv = [[UIView alloc] Initwithframe:cgrectmake (0,0, Kscreen_width, -)]; _LOGINBTN= [UIButton buttonwithstyle:strapsuccessstyle andtitle:@"Login"Andframe:cgrectmake ( -, Kscreen_width > the? -: -, kscreen_width- -*2, $) target:self Action: @selector (Sendlogin)];    [Footerv ADDSUBVIEW:_LOGINBTN]; returnFooterv;}

5: Hide the navigation bar on this page

-(void) viewdidload{    [Super Viewdidload];    [Self.navigationcontroller Setnavigationbarhidden:yes];}

6:uiedgeinsets

struct {cgfloat top, left, bottom, right;} Uiedgeinsets: The main thing is to understand the meaning of uiedgeinsets in the iOS UI. Uiedgeinsets==> This is actually the insertion interval area. Positive values indicate the interval value, and negative values indicate the distance beyond the reference.

7: Activity Indicator Uiactivityindicatorview

you can tell the user that an operation is in progress. Derived from UIView, so he is a view or can be attached to a view. Uiactivityindicatorview* Activityindicatorview = [[Uiactivityindicatorview alloc]?initwithframe:cgrectmake (250.0,20.0,30.0,30.0)]; set style: Activityindicatorview.activityindicatorviewstyle=Uiactivityindicatorviewstylegray; Uiactivityindicatorviewstylewhitelarge Large White indicator uiactivityindicatorviewstylewhite Standard size white indicator Uiactivityindicatorviewstylegray gray indicator for white background if you want the indicator to be automatically hidden after it stops, set the Hideswhenstoped property to Yes. The default is yes. The indicator will still appear after set to No stop. activityindicatorview.hideswhenstoped=No; display: You can attach it to any view, such as a table cell, or view, [Self.view Addsubview:activityindicatorview] Start and stop [Activityindicatorview Startanimating];//Start[Activityindicatorview stopanimating];//Stopdetermine if you are in motion state Isanimating[activityindicatorview isanimating] The following is an instance code _activityindicator=[[Uiactivityindicatorview alloc] Initwithactivityindicatorstyle:            Uiactivityindicatorviewstylegray]; Cgsize captchaviewsize=_captchaview.bounds.size; _activityindicator.hideswhenstopped=YES; [_activityindicator setcenter:cgpointmake (Captchaviewsize.width/2, captchaviewsize.height/2)]; [_captchaview Addsubview:_activityindicator];

8: Save user name and password using Nsuserdefaults

There are several ways to create a user defaults method, the simplest way to create it quickly: Nsuserdefaults*accountdefaults =[Nsuserdefaults standarduserdefaults]; add data to User Defaults:[accountdefaults SetObject:nameField.text Forkey: Userdefaultnamekey]; You can also add a base data type int,float, BOOL, etc., there are corresponding methods [Accountdefaults setbool:yes Forkey:userdefaultboolkey]; Get data from user defaults: [accountdefaults Objectforkey:ncuserdefaultnamekey] [accountdefaults Boolforkey:userdefaultboolkey]; Note: Userdefaults is not written immediately, Instead, the data in the cache is written to the local disk according to the timestamp. So after calling the set method, it is possible that the data has not yet been written to the disk application to terminate. You can force writes by calling the Synchornize method. [[Nsuserdefaults standarduserdefaults] synchronize]; Code snippet: Nsuserdefaults*defaults =[Nsuserdefaults Standarduserdefaults];        [Defaults setobject:[nsnumber numberwithbool:yes] forkey:kloginstatus];        [Defaults setobject:logindata forkey:kloginuserdict]; [Defaults synchronize];

iOS Client Coding Project record (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.