UITableView 多選刪除功能 IOS

2021-07-05 19:02:09 字數 2740 閱讀 1203

效果圖

首先在uitableview的 edittingstyleforrowatindexpath函式中,新增如下**

- (uitableviewcelleditingstyle)tableview:(uitableview *)tableview editingstyleforrowatindexpath:(nsindexpath *)indexpath
—-初始時設定tableview setediting=yes;具體的**實現和效果圖如下:

#import "duoxuantableview.h"

@inte***ce

duoxuantableview ()

@end

@implementation

duoxuantableview

@synthesize duoxiantable;

- (void)viewdidload

- (void)didreceivememorywarning

#pragma mark - tableview**方法

- (void)initduoxuantable

- (void)rightbtnpressedwithsure:(uibutton *)button else

if([button11.titlelabel

.text isequal:@"確定"])

[duoxiantable deleterowsatindexpaths:selecteddic withrowanimation:uitableviewrowanimationfade];

[selecteddic removeallobjects];

[duoxiantable setediting:no animated:yes];

[button11 settitle:@"刪除" forstate:uicontrolstatenormal];

[duoxiantable setediting:no animated:yes];

}else

}}#pragma -mark

#pragma tableview data source method

- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section

- (nsinteger)numberofsectionsintableview:(uitableview *)tableview

-(cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath

#pragma tableview delegate methods

- (uitableviewcelleditingstyle)tableview:(uitableview *)tableview editingstyleforrowatindexpath:(nsindexpath *)indexpath

- (bool)tableview:(uitableview *)tableview caneditrowatindexpath:(nsindexpath *)indexpath

#pragma tableview delegate methods

- (uitableviewcelleditingstyle)tableview:(uitableview *)tableview editingstyleforrowatindexpath:(nsindexpath *)indexpath

- (bool)tableview:(uitableview *)tableview caneditrowatindexpath:(nsindexpath *)indexpath

//新增一項

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath

}//取消一項

- (void)tableview:(uitableview *)tableview diddeselectrowatindexpath:(nsindexpath *)indexpath

}- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath

//#pragma mark-

#pragma alertview delegate method

- (void)alertview:(uialertview *)alertview clickedbuttonatindex:(nsinteger)buttonindex

}@end

效果圖如下:

js checkbox多選刪除

aspx前端 js 後台cs 執行刪除 public partial class default system.web.ui.page button1.click button1 click void button1 click object sender,eventargs e shuxin pu...

UITableView 新增,刪除,編輯

uitableviewcell tableview uitableview tableview cellforrowatindexpath nsindexpath indexpath cell.textlabel.text clocknum objectatindex indexpath.row c...

UITableView 的行刪除

uitableview 編輯模式 created by mj on 13 4 11.import mjviewcontroller.h inte ce mjviewcontroller property nonatomic,retain nsmutablearray data end impleme...