UITableViewDataSource TableView數據源協議,tableview

來源:互聯網
上載者:User

UITableViewDataSource TableView數據源協議,tableview

UITableViewDataSource TableView數據源協議
主要進行,資料的編輯(刪除,插入),索引,移動排序的操作,是否允許編輯(刪除,插入)和移動排序,設定顯示的行數,組數,儲存格的顯示
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
返回的是一組數據有多少行
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
cell訪問數據源然後加載到tableView
-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView;
返回有多少組,多少部分(默認是1,這個方法可以不實現)
-(NSString *)tableView:(UITableView *) titleForHeaderInSection:(NSInteger)section;
(固定的字體fixed font style,如果你想要不同的樣子,使用 custom view(UILabel))
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
控制行能否移動,return NO就不能執行排序操作了(比如移動按鈕不會出現了)
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath;

控制能否編輯,如果return NO 不能執行編輯操作了(比如刪除不會出現了)
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
要求的指定部分的表格視圖的頁首標題資料來源。
-(NSString *)tableVIew:(UITableView *)tableVIew titleForFooterInSection:(NSInteger)section;
要求的指定部分的表格視圖的頁尾標題資料來源。
-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView;
返回每組的標題,標題顯示在索引檢視表中
-(Integer)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index;
返回分組的索引位置(在這個方法裡面可以接收到索引的標題是什麼,如果寫成固定的值,那麼點擊索引不會對應的跳動了)
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle) editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;
對特定的行進行刪除跟插入的操作(editingStyle,編輯類型,可以通過他來區分是刪除還是插入

-(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath;
對資料來源將排在表視圖中的一個特定的位置到另一個位置。(排序的操作用這個方法操作)



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.