1. initialize a UITableView
1 - (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
1 struct CGRect {2 CGPoint origin;3 CGSize size;4 };5 typedef struct CGRect CGRect;
1 typedef enum {2 UITableViewStylePlain, // tile Style 3 UITableViewStyleGrouped // group style 4} UITableViewStyle;
2. configure a TableView
1) return the TableView style (read-only attribute)
1 @property(nonatomic, readonly) UITableViewStyle style
2) returns the number of cells in the specified section.
1 - (NSInteger)numberOfRowsInSection:(NSInteger)section
When TableView is in UITableViewStylePlain, the section should be 0
3) returns the number of TableView sections.
1 - (NSInteger)numberOfSections
4) set the height of all cells in TableView.
1 @property(nonatomic) CGFloat rowHeight
Apple recommends that you use the proxy method tableView: heightForRowAtIndexPath: instead of rowHeight to improve TableView performance.
5) set the style of the separation line of TableView
1 @property(nonatomic) UITableViewCellSeparatorStyle separatorStyle
1 typedef enum: NSInteger {2 UITableViewCellSeparatorStyleNone, // No separator line 3 Gb/s, // single split line 4 Gb/s // eroded but separator line 5} UITableViewCellSeparatorStyle;
6) set the separation line color of TableView
1 @property(nonatomic, retain) UIColor *separatorColor
7) set the background view of TableView
1 @property(nonatomic, readwrite, retain) UIView *backgroundView
8) set the separation line offset of TableView
1 @property (nonatomic) UIEdgeInsets separatorInset2 //Available in iOS 7.0 and later.
Apple example
1 tableView. separatorInset = UIEdgeInsetsMake (0, 3, 0, 11); 2 // top, left, bottom, right
3. Create a TableView Cell
1) register a nib object that contains a Cell with the specified identifier TableView.
1-(void) registerNib :( UINib *) nib forCellReuseIdentifier :( NSString *) identifier // the two parameters cannot be nil2 // Available in iOS 5.0 and later.
2) register a class to create a Cell
1 - (void)registerClass:(Class)cellClass forCellReuseIdentifier:(NSString *)identifier2 //Available in iOS 6.0 and later.
3) return reusable cells with the specified identifier
1 - (id)dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath2 //Available in iOS 6.0 and later.
Note: before using this method, you must use registerNib: forCellReuseIdentifier: Or registerClass: forCellReuseIdentifier: The method registers the Cell.
4) return reusable cells with the specified identifier
1 - (id)dequeueReusableCellWithIdentifier:(NSString *)identifier
4. Access the view at the header and end of the table
1) register a nib object that contains the specified identifier table view at the header or end of the table.
1 - (void)registerNib:(UINib *)nib forHeaderFooterViewReuseIdentifier:(NSString *)identifier2 //Available in iOS 6.0 and later.
2) register a class to create a new table view that contains the header or the end of the table.
1 - (void)registerClass:(Class)aClass forHeaderFooterViewReuseIdentifier:(NSString *)identifier2 //Available in iOS 6.0 and later.
3) returns a reusable view with the end of the header table with the specified identifier.
1 - (id)dequeueReusableHeaderFooterViewWithIdentifier:(NSString *)identifier2 //Available in iOS 6.0 and later.
4) set or return the table header view.
1 @property(nonatomic, retain) UIView *tableHeaderView
5) set or return the end view of the table.
1 @property(nonatomic, retain) UIView *tableFooterView
6) set or return the table header height
1 @property(nonatomic) CGFloat sectionHeaderHeight
7) set or return the end height of the table.
1 @property(nonatomic) CGFloat sectionFooterHeight
8) returns the header view of the specified section.
1 - (UITableViewHeaderFooterView *)headerViewForSection:(NSInteger)section2 //Available in iOS 6.0 and later.
9) returns the end view of the table of the specified section.
1 - (UITableViewHeaderFooterView *)footerViewForSection:(NSInteger)section2 //Available in iOS 6.0 and later.
5. Access Cell and Section
1) return the Cell of the specified indexPath
1 - (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath
2) returns the IndexPath of the specified Cell.
1 - (NSIndexPath *)indexPathForCell:(UITableViewCell *)cell
3) returns the IndexPath of the specified vertex.
1 - (NSIndexPath *)indexPathForRowAtPoint:(CGPoint)point
4) returns an array consisting of IndexPath in the specified region.
1 - (NSArray *)indexPathsForRowsInRect:(CGRect)rect
5) returns an array composed of visible uitableviewcells.
1 - (NSArray *)visibleCells
6) returns an array consisting of IndexPath of the rows in the visible table.
1 - (NSArray *)indexPathsForVisibleRows
6. Estimate the height of an element
1) set the estimated height of table rows to improve performance
1 @property (nonatomic) CGFloat estimatedRowHeight2 //The default value is 0, which means there is no estimate.3 //Available in iOS 7.0 and later.
2) set the height of the Section header to improve performance
1 @property(nonatomic) CGFloat estimatedSectionHeaderHeight2 //The default value is 0, which means there is no estimate.3 //Available in iOS 7.0 and later.
3) set the ancient capitals at the end of the Section to improve performance.
1 @property(nonatomic) CGFloat estimatedSectionFooterHeight2 //The default value is 0, which means there is no estimate.3 //Available in iOS 7.0 and later.
7. Scroll through TableView
1) scroll to the specified position
1 - (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated
1 typedef enum {2 UITableViewScrollPositionNone,3 UITableViewScrollPositionTop,4 UITableViewScrollPositionMiddle,5 UITableViewScrollPositionBottom6 } UITableViewScrollPosition;
To be Continue...