天天看點

iphone/ipad開發之UITableView的方法

1.-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;

//傳入一個tableview

//傳回tableview的區數

2. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;

//傳入一個tableview和該tableview的特定分區section
 //傳回該分區中行數

3. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

 //傳入一個tableview與該tableview的某行索引
//從索引路徑擷取分區和行,用來确定使用哪個值

 4. -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;

//傳入一個tableview和該tableview的特定分區section
//傳回每個分區的标題值,可以自定義,這裡得到分區名

5.- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView;

//傳入一個tableview

//傳回該tableview的分區索引

6. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

//點選一個cell後觸發的事件

7. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 

 //設定行高

8.-(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath;

//此方法将縮進級别設定為行号,傳回縮進數字

 9.-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath; 

 //點選一個cell前觸發的事件

10.-(UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath {return UITableViewCellAccessoryDisclosureIndicator;} 

//每一行都顯示一個展示按鈕