UITableView 的一些小知識

來源:互聯網
上載者:User

typedef enum {
    UITableViewCellSelectionStyleNone,
    UITableViewCellSelectionStyleBlue,
    UITableViewCellSelectionStyleGray
} UITableViewCellSelectionStyle
//cell右邊按鈕格式
typedef enum {
    UITableViewCellAccessoryNone,                   // don't show any accessory view
    UITableViewCellAccessoryDisclosureIndicator,    // regular chevron. doesn't track
    UITableViewCellAccessoryDetailDisclosureButton, // blue button w/ chevron. tracks
    UITableViewCellAccessoryCheckmark               // checkmark. doesn't track
} UITableViewCellAccessoryType
//是否加換行線
typedef enum {
    UITableViewCellSeparatorStyleNone,
    UITableViewCellSeparatorStyleSingleLine
} UITableViewCellSeparatorStyle//改變換行線顏色

 

1.點擊某一個cell後,將會進入另一個View,返回又回到原始View的最頂端,怎麼樣才能還返回在點擊之前的那個位置呢?

NSIndexPath *ip = [ NSIndexPath  indexPathForRow:row  inSection:section ];

[TopicsTable  selectRowAtIndexPath: ip  animated: YES  scrollPosition : UITableViewScrollPositionNone ];

2.選中Cell響應事件

-(void)tableView:(UITableView *)tableView  didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    [tableView  deselectRowAtIndexPath:indexPath  animated:YES];  //選中後的返現顏色即刻消失

}

3.在程式中,有時候會不想讓使用者去點擊某一行,可以這樣做:

- (NSIndexPath *)tableView :(UITableView *)tableView  willSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    NSUInteger  row = [indexPath row];

    if( row == 0)  return nil;  //阻止選中第一行

    return  indexPath;

}

4.滑動cell是否出現del按鈕

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{

   

}

5.編輯狀態

- (void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{

    [topicsTable setContentSize:CGSizeMake(0,controller.promiseNum * 44)];

}

6.右側添加一個索引表

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableVIew{

 


}

7.返回標題section標題內容

- (NSString *)tableView:(UITableView *)tableView titleForHeardInSection:(NSInteger)section{

}

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.