iOS Client Coding Project record (iv)

Source: Internet
Author: User

1: Open Xcode, then flash back, report loading a library with an exception

such as/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/lib/  Libclang.dylib This is the Xcode bug, my situation is to open a project will appear this problem resolution: This is still a cache problem, see 5th (5, XCODE5 because of the cache problem caused a lot of strange problems, So clearing the cache can sometimes play a big role:), clear the cache and run, everything is OK. Enter the step, press the OPTION key to enter the library, developer-xcode-deriveddata the file inside to clear can

2: Speed up the Cocoapod installation plug-in

--no-repo-update

3:userinteractionenabled Property

*headerview == YES;

4: String display problem, different effect on same line

call: [_fanscountbtn setattributedtitle:[self Getstringwithtitle:@"fans"Andvalue:_curuser.fans_count.stringvalue] Forstate:uicontrolstatenormal]; Method:-(nsmutableattributedstring*) Getstringwithtitle: (NSString *) title Andvalue: (NSString *) value{nsmutableattributedstring*attristring = [[Nsmutableattributedstring alloc] initwithstring:[nsstring stringWithFormat:@"%@ %@", value, title]]; [Attristring addattributes:@{nsfontattributename: [Uifont boldsystemfontofsize: -], nsforegroundcolorattributename: [Uicolor Whitecolor]} rang E:nsmakerange (0, Value.length)]; [Attristring addattributes:@{nsfontattributename: [Uifont systemfontofsize: -], nsforegroundcolorattributename: [Uicolor Whitecolor]} rang E:nsmakerange (Value.length+1, Title.length)]; returnattristring;} Another: Label can call SizeToFit to adjust content adaptation _userlabel.text=_curuser.name; [_userlabel SizeToFit];

Using Firstobject and Lastobject in 5:nsarray

 Nsarray has the Lastobject method to get the last object of the array, firstobject to get the first object of the array, the advantage of using Firstobject and Lastobject in Nsarray is that when the array is empty, nil is returned , without error. When the array is empty, use Myarray[0   "error. NSNumber  *firstlevel = nil, *secondlevel = nil; Nsarray  *locationarray = [_curuser.location componentsseparatedbystring:@ "                          ";  if  (Locationarray.count = = 2  Span style= "color: #000000;" ) {firstlevel  = [Addressmanager Indexoffirst:[locationar                            Ray Firstobject]]; Secondlevel  = [Addressmanager Indexofsecond:[locationarray Lastobject] InFirst                        : [Locationarray Firstobject]]; }

6: Date control Actionsheetdatepicker Multilevel control Actionsheetstringpicker

Small Example: NSDate*curdate = [NSDate datefromstring:_curuser.birthday withformat:@"YYYY-MM-DD"]; if(!curdate) {Curdate= [NSDate datefromstring:@"1990-01-01"Withformat:@"YYYY-MM-DD"]; } Actionsheetdatepicker*picker = [[Actionsheetdatepicker alloc] Initwithtitle:nil datepickermode:uidatepickermodedate selectedDate:curDate doneblock:^ (Actionsheetdatepicker *picker, NSDate *selectedDate, id origin) {NSString*prevalue =WeakSelf.curUser.birthday; WeakSelf.curUser.birthday=[SelectedDate STRING_YYYY_MM_DD];                        [Weakself.mytableview Reloaddata]; [[Coding_netapimanager Sharedmanager] request_UpdateUserInfo_WithObj:weakSelf.curUser andblock:^ (ID data, Nserror *error) {                            if(data) {Weakself.curuser=data; }Else{weakSelf.curUser.birthday=Prevalue;                        } [Weakself.mytableview Reloaddata];                    }]; } Cancelblock:^ (Actionsheetdatepicker *picker) {NSLog (@"%@", picker.description);                    } Origin:self.view]; Picker.minimumdate= [[NSDate Date] offsetyear:- -]; Picker.maximumdate=[NSDate Date]; [Picker showactionsheetpicker]; small instance: [Actionsheetstringpicker showpickerwithtitle:nil Rows:@[[addressmanager Firstlevelarray], [Addressmanager Secondlevelmap]] initialselection:@[firstlevel, Secondlevel] DoneBlock:^ (Actionsheetstringpicker *picker, Nsarray * selectedindex, Nsarray *SelectedValue) {NSString*prevalue =weakSelf.curUser.location; NSString*location = [SelectedValue componentsjoinedbystring:@" "]; WeakSelf.curUser.location=Location ;                        [Weakself.mytableview Reloaddata]; [[Coding_netapimanager Sharedmanager] request_UpdateUserInfo_WithObj:weakSelf.curUser andblock:^ (ID data, Nserror *error) {                            if(data) {Weakself.curuser=data; }Else{weakSelf.curUser.location=Prevalue;                        } [Weakself.mytableview Reloaddata];                    }]; } Cancelblock:nil Origin:self.view]; small instance: [Actionsheetstringpicker showpickerwithtitle:nil rows:@[@[@"male",@"female",@"Unknown"]] Initialselection:@[_curuser.sex] doneblock:^ (actionsheetstringpicker *picker, Nsarray * selectedIndex, NSArray *SelectedValue) {NSNumber*prevalue =WeakSelf.curUser.sex; WeakSelf.curUser.sex=[SelectedIndex Firstobject];                        [Weakself.mytableview Reloaddata]; [[Coding_netapimanager Sharedmanager] request_UpdateUserInfo_WithObj:weakSelf.curUser andblock:^ (ID data, Nserror *error) {                            if(data) {Weakself.curuser=data; }Else{weakSelf.curUser.sex=Prevalue;                        } [Weakself.mytableview Reloaddata];                    }]; } Cancelblock:nil Origin:self.view];

7: Code auto-Layout Masonry plugin

Masonry supports which properties @property (Nonatomic, Strong,ReadOnly) Masconstraint *Left ; @property (nonatomic, Strong,ReadOnly) Masconstraint *top; @property (nonatomic, Strong,ReadOnly) Masconstraint *Right ; @property (nonatomic, Strong,ReadOnly) Masconstraint *Bottom, @property (nonatomic, Strong,ReadOnly) Masconstraint *Leading, @property (Nonatomic, Strong,ReadOnly) Masconstraint *trailing, @property (nonatomic, Strong,ReadOnly) Masconstraint *width; @property (nonatomic, Strong,ReadOnly) Masconstraint *height; @property (nonatomic, Strong,ReadOnly) Masconstraint *CenterX, @property (nonatomic, Strong,ReadOnly) Masconstraint *CenterY, @property (nonatomic, Strong,ReadOnly) Masconstraint *baseline; small example:if(!_titlel) {_titlel=[[UILabel alloc] init];            [Self.contentview Addsubview:_titlel]; _titlel.font= [Uifont systemfontofsize: -]; _titlel.textcolor=[Uicolor Blackcolor]; }        if(!_valuel) {_valuel=[[UILabel alloc] init]; _valuel.numberoflines=0;            [Self.contentview Addsubview:_valuel]; _valuel.font= [Uifont systemfontofsize: the]; _valuel.textcolor= [Uicolor colorwithhexstring:@"0x999999"]; } [_titlel mas_makeconstraints:^ (Masconstraintmaker *Make )            {Make.left.equalTo (Self.contentview). Offset (kpaddingleftwidth); Make.height.mas_equalTo ( -); Make.top.equalTo (Self.contentview). Offset ( A); Make.width.mas_equalTo (Kscreen_width-2*kpaddingleftwidth);        }]; [_valuel mas_makeconstraints:^ (Masconstraintmaker *Make ) {Make.top.equalTo (_titlel.mas_bottom). Offset ( A);        Make.left.right.equalTo (_titlel); }]; Good article: http://www.cocoachina.com/ios/20141219/10702.html

iOS Client Coding Project record (iv)

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.