UI基礎:UITableView的編輯和移動

來源:互聯網
上載者:User

標籤:

相對UITableViiew進行編輯,必須設定代理UITableViewDataSource和UITableViewDelegate.因為需要它們為UITableViiew實現幾個必須的方法.

UITableView的編輯和移動都遵循四步操作:

1.讓tableView處於可編輯狀態(UIViewController中的方法)

2.設定哪些行可以編輯(UITableViewDataSource中的方法)

3.設定編輯的樣式(UITableViewDelegate中的方法)

4.提交編輯(a.修改資料來源 b.修改介面)(UITableViewDataSource)

 

設定tableVIew處於可編輯狀態

-(void)setEditing:(BOOL)editing animated:(BOOL)animated;

設定tableView那哪些行可以編輯

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

指定編輯樣式

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath;

提交編輯結果,這個方法在點擊done時觸發

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

 

在最後一步中,需要實現兩個功能:1.修改資料來源2.更新介面

 

UI基礎:UITableView的編輯和移動

聯繫我們

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