Small and iOS knowledge points in iOS

Source: Internet
Author: User

Small and iOS knowledge points in iOS

1. Hide the scroll bar in tableView

   self.tableView.showsVerticalScrollIndicator = NO;

2. About attributes

Use assign: Use copy for basic data types (NSInteger, CGFloat) and C data types (int, float, double, char, etc.): Use retain (strong) for NSString ): for other NSObject and its subclass 3. register cell
// Register cell [self. tableView registerNib: [UINib nibWithNibName: NSStringFromClass ([DDZRecommendCategoryCell class]) bundle: nil] forCellReuseIdentifier: @ "category"];

 

4. Reuse cell

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"category"];

 

5. Refresh the page

        [self.tableView reloadData];

Generally, the update display function is used after the server data is requested.

 

6. appearance uniformly sets the appearance

// Set NSMutableDictionary * attrs = [NSMutableDictionary dictionary] In appearance; attrs [dictionary] = [UIFont systemFontOfSize: 13]; attrs [interval] = [UIColor grayColor]; // set the appearance of item (condition: UI_APPEARANCE_SELECTOR is followed by the method) UITabBarItem * item = [UITabBarItem appearance]; [item setTitleTextAttributes: attrs forState: UIControlStateNormal]

 

7. Use your custom tabbar

// Change the tabBar (use KVC to directly change the member variable) [self setValue: [[DDZTabBar alloc] init] forKey: @ "tabBar"];

In your tabber class

Use-(void) layoutSubviews to adjust the position of the internal subview

 

8. Make your code called only once

For example, appearance can be set once.

+ (void)initialize

 

9. The first line is selected by default in tableView.

// By default, the first line [self. tableView selectRowAtIndexPath: [NSIndexPath indexPathForRow: 0 inSection: 0] animated: NO scrollPosition: UITableViewScrollPositionTop] is selected.

 

10. Set insert (the displayed content is blocked in the navigation bar of UITbaleView)

// Set insert self. automaticallyAdjustsScrollViewInsets = NO; self. tableView. contentInset = UIEdgeInsetsMake (64, 0, 0, 0 );

 

11. Set the cell height (the default cell height is 44)

self.tableView.rowHeight = 70;

 

 

 

 

 

 

 

 

 

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.