国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

UITableView屬性和方法

2019-11-14 20:27:42
字體:
供稿:網(wǎng)友

1、初始化一個(gè)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, //平鋪樣式3    UITableViewStyleGrouped //分組樣式4 } UITableViewStyle;

 

2、配置一個(gè)TableView

1)返回這個(gè)TableView的樣式(只讀屬性)

1 @PRoperty(nonatomic, readonly) UITableViewStyle style

 

2)返回指定section內(nèi)的Cell的行數(shù) 

1 - (NSInteger)numberOfRowsInSection:(NSInteger)section

 

 當(dāng)TableView在UITableViewStylePlain下section應(yīng)該為0

3)返回TableView的section數(shù)量

1 - (NSInteger)numberOfSections

 

4)設(shè)置TableView中所有cell的高度

1 @property(nonatomic) CGFloat rowHeight

 

Apple建議我們使用代理方法tableView:heightForRowAtIndexPath:代替rowHeight方法使TableView的性能更高

5)設(shè)置TableView的分隔線的樣式

1 @property(nonatomic) UITableViewCellSeparatorStyle separatorStyle
1 typedef enum : NSInteger {2    UITableViewCellSeparatorStyleNone, //無分隔線3    UITableViewCellSeparatorStyleSingleLine, //單分割線4    UITableViewCellSeparatorStyleSingleLineEtched //被侵蝕的但分隔線5 } UITableViewCellSeparatorStyle;

 

6)設(shè)置TableView的分隔線顏色

1 @property(nonatomic, retain) UIColor *separatorColor

 

7)設(shè)置TableView的背景視圖

1 @property(nonatomic, readwrite, retain) UIView *backgroundView

 

8)設(shè)置TableView的分隔線偏移量

1 @property (nonatomic) UIEdgeInsets separatorInset2 //Available in iOS 7.0 and later.

 

Apple的例子

1 tableView.separatorInset = UIEdgeInsetsMake(0, 3, 0, 11);2 //上、左、下、右

 


 

3、創(chuàng)建TableView的Cell

1)注冊(cè)一個(gè)包含指定標(biāo)示符TableView的Cell的nib對(duì)象

1 - (void)registerNib:(UINib *)nib forCellReuseIdentifier:(NSString *)identifier //兩個(gè)參數(shù)不能是nil2 //Available in iOS 5.0 and later.

 

2)注冊(cè)一個(gè)類用來創(chuàng)建新的Cell

1 - (void)registerClass:(Class)cellClass forCellReuseIdentifier:(NSString *)identifier2 //Available in iOS 6.0 and later.

 

3)使用指定的標(biāo)示符返回可重用的Cell

1 - (id)dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath2 //Available in iOS 6.0 and later.

 

Apple重要提示:使用這個(gè)方法之前必須是使用了registerNib:forCellReuseIdentifier: 或者registerClass:forCellReuseIdentifier:方法注冊(cè)了Cell

4)使用指定的標(biāo)示符返回可重用的Cell

1 - (id)dequeueReusableCellWithIdentifier:(NSString *)identifier

 

4、訪問表頭和表尾的視圖

1)注冊(cè)一個(gè)包含表頭或表尾的指定標(biāo)示符表視圖的nib對(duì)象

1 - (void)registerNib:(UINib *)nib forHeaderFooterViewReuseIdentifier:(NSString *)identifier2 //Available in iOS 6.0 and later.

 

2)注冊(cè)一個(gè)類,用來創(chuàng)建新的包含表頭或表尾的表視圖

1 - (void)registerClass:(Class)aClass forHeaderFooterViewReuseIdentifier:(NSString *)identifier2 //Available in iOS 6.0 and later.

 

3)返回一個(gè)指定標(biāo)識(shí)符的可重用的附帶表頭表尾的視圖

1 - (id)dequeueReusableHeaderFooterViewWithIdentifier:(NSString *)identifier2 //Available in iOS 6.0 and later.

 

4)設(shè)置或返回該表格的表頭視圖

1 @property(nonatomic, retain) UIView *tableHeaderView

 

5)設(shè)置或返回該表格的表尾視圖

1 @property(nonatomic, retain) UIView *tableFooterView

 

6)設(shè)置或返回該表格的表頭高度

1 @property(nonatomic) CGFloat sectionHeaderHeight

 

7)設(shè)置或返回該表格的表尾高度

1 @property(nonatomic) CGFloat sectionFooterHeight

 

8)返回指定section的表頭視圖

1 - (UITableViewHeaderFooterView *)headerViewForSection:(NSInteger)section2 //Available in iOS 6.0 and later.

 

9)返回指定section的表尾視圖

1 - (UITableViewHeaderFooterView *)footerViewForSection:(NSInteger)section2 //Available in iOS 6.0 and later.

 


 

5、訪問Cell和Section

1)返回指定indexPath的Cell

1 - (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath

 

2)返回指定Cell的IndexPath

1 - (NSIndexPath *)indexPathForCell:(UITableViewCell *)cell

 

3)返回指定點(diǎn)的IndexPath

1 - (NSIndexPath *)indexPathForRowAtPoint:(CGPoint)point

 

4)返回指定區(qū)域內(nèi)的IndexPath組成的數(shù)組

1 - (NSArray *)indexPathsForRowsInRect:(CGRect)rect

 

5)返回可見的UITableViewCell組成的數(shù)組

1 - (NSArray *)visibleCells

 

6)返回可見表格行的IndexPath組成的數(shù)組

1 - (NSArray *)indexPathsForVisibleRows

 

6、估算元素的高度

1)設(shè)置表格行的估算高度以改善性能

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)設(shè)置Section頭的估算高度以改善性能

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)設(shè)置Section尾的古都按高度以改善性能

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、滾動(dòng)TableView

1)滾動(dòng)到指定的位置

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...


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 噶尔县| 天台县| 江安县| 昭觉县| 常熟市| 开封市| 饶阳县| 崇明县| 万山特区| 翁源县| 和田县| 民乐县| 浙江省| 安阳市| 锡林浩特市| 金寨县| 青海省| 富平县| 宁都县| 元朗区| 齐齐哈尔市| 肥乡县| 隆子县| 冀州市| 苏尼特左旗| 昭平县| 阜康市| 麦盖提县| 沙田区| 宁陕县| 海丰县| 雷州市| 逊克县| 镶黄旗| 刚察县| 漠河县| 台中县| 乌鲁木齐县| 桐乡市| 泗水县| 涡阳县|