IOS client Coding project record (4), ios client coding project

Source: Internet
Author: User

IOS client Coding project record (4), ios client coding project

1: Open Xcode and crash. An exception occurs when loading a database.

For example,/Applications/Xcode. app/Contents/Developer/Toolchains/XcodeDefault. xctoolchain/usr/lib/libclang. dylib is a Xcode bug. In my case, this problem occurs when a project is opened. Solution: This is a cache problem, for details, refer to the fifth point (5. XCode5 has caused many strange problems due to cache problems, so clearing the cache sometimes plays a major role :). Clear the cache and run it again. Everything is normal. Go to the step and press the option key to enter the resource library. The Developer-xcode-DerivedData can clear the files in the resource library.

2: Accelerate CocoaPod plugin installation

(This also solves some plug-in download failure issues, because some source code content is unnecessary, but the provided address is not connected, resulting in an error, but cannot be updated) $ pod install -- no-repo-update

3: userInteractionEnabled attribute

When the view object's userInteractionEnabled is set to NO, user-triggered events, such as touch and keyboard, will be ignored by this view (other views will respond as usual ), the view object will also be removed from the event response queue. When userInteractionEnabled is set to YES, the event can be passed to the view object normally. The default value of userInteractionEnabled is YES. EaseUserHeaderView * headerView = [[EaseUserHeaderView alloc] init]; headerView. userInteractionEnabled = YES;

4: String display problems, different effects on the same line

Call: [_ fansCountBtn setAttributedTitle: [self getStringWithTitle: @ "" andValue: _ curUser. fans_count.stringValue] forState: UIControlStateNormal]; Method:-(optional *) getStringWithTitle :( NSString *) title andValue :( NSString *) value {optional * attriString = [NSMutableAttributedString alloc] initWithString: [NSString stringWithFormat: @ "% @", value, title]; [attriString addAttributes :@ {NSFontAttributeName: [UIFont boldSystemFontOfSize: 17], NSForegroundColorAttributeName: [UIColor whiteColor]} range: NSMakeRange (0, value. length)]; [attriString addAttributes: @ {NSFontAttributeName: [UIFont systemFontOfSize: 14], NSForegroundColorAttributeName: [UIColor whiteColor]} range: NSMakeRange (value. length + 1, title. length)]; return attriString;} another: the label can call sizeToFit to adjust the content to adapt to _ userLabel. text = _ curUser. name; [_ userLabel sizeToFit];

5: Use firstObject and lastObject in NSArray

NSArray has the lastObject method used to obtain the last object of the array. firstObject is used to obtain the first object of the array. The advantage of firstObject and lastObject in NSArray is that when the array is empty, nil is returned, no error is reported. If the array is empty and myArray [0] is used, an error is returned. NSNumber * firstLevel = nil, * secondLevel = nil; NSArray * locationArray = [_ curUser. location componentsSeparatedByString: @ ""]; if (locationArray. count = 2) {firstLevel = [AddressManager indexOfFirst: [locationArray firstObject]; secondLevel = [AddressManager indexOfSecond: [locationArray lastObject] inFirst: [locationArray firstObject];}

6: Date control ActionSheetDatePicker multi-level control ActionSheetStringPicker

Small instance: NSDate * curDate = [NSDate dateFromString: _ curUser. birthday withFormat: @ "yyyy-MM-dd"]; if (! CurDate) {curDate = [NSDate dateFromString: @ "1990-01-01" withFormat: @ "yyyy-MM-dd"];} ActionSheetDatePicker * picker = [[externalloc] 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:-120]; picker. maximumDate = [NSDate date]; [picker showActionSheetPicker]; small instance: [partition sequence: 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: Automatic Code layout Masonry plug-in

What attributes does Masonry support? @ 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 (nonatom Ic, 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 instance: if (! _ TitleL) {_ titleL = [[UILabel alloc] init]; [self. contentView addSubview: _ titleL]; _ titleL. font = [UIFont systemFontOfSize: 16]; _ titleL. textColor = [UIColor blackColor];} if (! _ ValueL) {_ valueL = [[UILabel alloc] init]; _ valueL. numberOfLines = 0; [self. contentView addSubview: _ valueL]; _ valueL. font = [UIFont systemFontOfSize: 15]; _ valueL. textColor = [UIColor colorWithHexString: @ "0x999999"];} [_ titleL mas_makeConstraints: ^ (MASConstraintMaker * make) {make. left. similar to (self. contentView ). offset (kPaddingLeftWidth); make. height. mas_tables to (20); make. top. similar to (self. contentView ). offset (12); make. width. mas_shortto (kScreen_Width-2 * kPaddingLeftWidth);}]; [_ valueL mas_makeConstraints: ^ (MASConstraintMaker * make) {make. top. pointer to (_ titleL. mas_bottom ). offset (12); make. left. right. similar to (_ titleL);}]; good article: http://www.cocoachina.com/ios/20141219/10702.html

 

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.