Basic knowledge of IOS development-fragment 9, basic knowledge of ios-Fragment

Source: Internet
Author: User

Basic knowledge of IOS development-fragment 9, basic knowledge of ios-Fragment

1: Delete All nsuserults ults records in two ways

// Method 1 NSString * appDomain = [[NSBundle mainBundle] bundleIdentifier]; [[NSUserDefaults standardUserDefaults] removePersistentDomainForName: appDomain]; // method 2-(void) resetDefaults {NSUserDefaults * defs = [NSUserDefaults standardUserDefaults]; NSDictionary * dict = [defs dictionaryRepresentation]; for (id key in dict) {[defs removeObjectForKey: key];} [defs synchronize];}

2: set global navigation barbuttonitem

# Pragma mark sets global navigation barbuttonitem-(void) setNaviBarButtonItemImage :( NSString *) imageName andX :( NSInteger) x andY :( NSInteger) y andW :( NSInteger) w andH :( NSInteger) h andTitle :( NSString *) title andSel :( SEL) sel andLOrR :( NSString *) lOr andTitleColor :( UIColor *) color {UIButton * btn = [UIButton buttonWithType: UIButtonTypeCustom]; btn. frame = CGRectMake (x, y, w, h); [btn setTitle: title forState: UIControlS TateNormal]; if (imageName. length = 0 & title. length = 0) {} else if (imageName. length = 0 & title. length! = 0) {[btn setBackgroundColor: [UIColor clearColor]; [btn setTitleColor: color forState: UIControlStateNormal];} else if (imageName. length! = 0 & title. length = 0) {UIImage * image = [UIImage imageNamed: imageName]; [btn setImage: image forState: UIControlStateNormal];} else if (imageName. length! = 0 & title. length! = 0) {UIImage * image = [UIImage imageNamed: imageName]; [btn setBackgroundImage: image forState: UIControlStateNormal]; [btn setBackgroundColor: [UIColor clearColor]; [btn setTitleColor: color forState: UIControlStateNormal];} [btn addTarget: self action: sel forControlEvents: role]; UIBarButtonItem * bBtn = [[UIBarButtonItem alloc] Priority: btn]; if ([lOr isw.tostring: @ "left"]) {[self. navigationItem setLeftBarButtonItem: bBtn];} else {[self. navigationItem setRightBarButtonItem: bBtn] ;}}

3: Set Section spacing in UITableView

When Using IOS UITableView, its UITableViewStyleGrouped attributes are often used. By default, the spacing between sections after this attribute is used is relatively large, and it looks uncomfortable. You can use the following proxy method to configure the spacing of each section of UITableView. The principle is actually very simple. The spacing of each section in the display effect is actually a combination of the section header and the bottom. Configuring their spacing is to configure the headers and the bottom of each section // section header spacing-(CGFloat) tableView :( UITableView *) tableView heightForHeaderInSection :( NSInteger) section {return 1; // section header height} // section header view-(UIView *) tableView :( UITableView *) tableView viewForHeaderInSection :( NSInteger) section {UIView * view = [[UIView alloc] initWithFrame: CGRectMake (0, 0,320, 1)]; view. backgroundColor = [UIColor clearColor]; return [view autorelease];} // The spacing at the bottom of a section-(CGFloat) tableView :( UITableView *) tableView heightForFooterInSection :( NSInteger) section {return 1 ;} // view at the bottom of section-(UIView *) tableView :( UITableView *) tableView viewForFooterInSection :( NSInteger) section {UIView * view = [[UIView alloc] initWithFrame: CGRectMake (0, 0,320, 1)]; view. backgroundColor = [UIColor clearColor]; return [view autorelease];}

4: solve the problem that OBJC_CLASS _ $ _ MBProgressHUD cannot be referenced.

Although the related file has been updated with the POD, it has not been introduced into the project. You need to manually reference it (or directly discard the pod to manage this plug-in, directly introduce the project Source Code) Undefined symbols for architecture i386: "_ OBJC_CLASS _ $ _ MBProgressHUD", referenced from: objc-class-ref in ViewController. old: symbol (s) not found for architecture imo-clang: error: linker command failed with exit code 1 (use-v to see invocation) the error here is because you did not reference the relevant header file in building phases. Therefore, you only need to add the corresponding header file in building phase. m file.

5: An error occurred while refreshing the navigation bar via the SVPullToRefresh drop-down in iOS7.

An error occurred while refreshing the navigation bar via the SVPullToRefresh drop-down in iOS7; after the pull-down refresh, the first column of tableview will go to the navigation bar; correction: Add the following code/*** add one from the pull-down refresh; * // fix the error code starting from the drop-down refresh position. if ([self respondsToSelector: @ selector (automaticallyAdjustsScrollViewInsets)]) {self. automaticallyAdjustsScrollViewInsets = NO; UIEdgeInsets insets = self. tableView. contentInset; insets. top = self. navigationController. navigationBar. bounds. size. height + [UIApplication sharedApplication]. statusBarFrame. size. height; self. tableView. contentInset = insets; self. tableView. scrollIndicatorInsets = insets;} // fixed the error code ending _ block RootViewController * bSelf = self in the pull-down refresh position. [self. tableView addPullToRefreshWithActionHandler: ^ {[bSelf addRows];}];/*** pull to the end to load more and add one; */[self. tableView addInfiniteScrollingWithActionHandler: ^ {[bSelf addMoreRow];}];

 6: When you want to update the layout

CGRect headFrame=self.headerView.frame;headFrame.size.height=200;self.headerView.frame = headFrame;[self.headerView setNeedsLayout];[self.headerView layoutIfNeeded];

7. Add a rightView button to the right of UITextField)

UIButton *addCommentBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 40,inputTextViewHeight)];[addCommentBtn setImage:[UIImage imageNamed:@"textViewEditNormal"] forState:UIControlStateNormal];[addCommentBtn addTarget:self action:@selector(addCommentAction) forControlEvents:UIControlEventTouchUpInside];_inputTextView.rightView=addCommentBtn;_inputTextView.rightViewMode=UITextFieldViewModeAlways;

8: NSLog output format set

• % @ Object • % d, % I integer • % u unsigned integer • % f floating point/double-character • % x, % X binary integer • % o octal integer • % zu size_t • % p pointer • % e floating point/double character (Scientific Computing) • % g floating point/Double Character • % s C string • %. * s Pascal string • % c character • % C unichar • % lld 64-bit long integer (long) • % llu no character 64-bit long integer % Lf 64-bit double character

9: Set the rendering mode of UIImage: UIImage. renderingMode

Set the rendering mode of UIImage: UIImage. renderingMode coloring (Tint Color) is one of the iOS7 interfaces. set the rendering mode of UIImage: UIImage. renderingMode is significantly changed. You can set whether a UIImage uses the Tint Color of the current view during rendering. UIImage adds a read-only attribute: renderingMode, which corresponds to another method: imageWithRenderingMode:. It uses the UIImageRenderingMode enumeration value to set the renderingMode attribute of the image. This enumeration contains the following values: 1 UIImageRenderingModeAutomatic // The rendering mode is automatically adjusted based on the image's use environment and drawing context. 2 UIImageRenderingModeAlwaysOriginal // always draw the original status of the image without using Tint Color. 3 UIImageRenderingModeAlwaysTemplate // always draw an image based on Tint Color, ignoring the Color information of the image. The default value of the renderingMode attribute is UIImageRenderingModeAutomatic, that is, whether or not the UIImage uses Tint Color depends on the position it is displayed. UIImage * img = [UIImage imageNamed: @ "myimage"]; img = [img imageWithRenderingMode: UIImageRenderingModeAlwaysTemplate, the color will appear in blue. If you want to make the original color of the image, you need to modify the rendering of the image because it is currently rendered as the color of the text): @ property (weak, nonatomic) IBOutlet UIBarButtonItem * mycollectionItem; UIImage * collectionItemImage = [UIImage imageNamed: @ "bottomCollectionNormal"]; collectionItemImage = [collectionItemImage imageWithRenderingMode: Custom]; self. mycollectionItem. image = collectionItemImage;

10: the current page of navigationController is hidden, and the jump back page is also hidden.

Hidden code on the current page: [self. navigationController setNavigationBarHidden: YES]; jump time: [self. navigationController setNavigationBarHidden: NO]; [self. navigationController popViewControllerAnimated: YES];

 

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.