@@ -395,7 +395,7 @@ -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *
395
395
{
396
396
if (self.selectEnable ) {
397
397
if (!self.multiSelect && self.lastSelected ) {
398
- [tableView deselectRowAtIndexPath: self .lastSelected animated: YES ];
398
+ [tableView deselectRowAtIndexPath: self .lastSelected animated: NO ];
399
399
}
400
400
self.lastSelected = indexPath;
401
401
return ;
@@ -414,12 +414,12 @@ -(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath
414
414
415
415
// /editing
416
416
- (UITableViewCellEditingStyle)tableView : (UITableView *)tableView editingStyleForRowAtIndexPath : (NSIndexPath *)indexPath {
417
- if (DWRespond) {
418
- return [DWDelegate dw_TableView: tableView editingStyleForRowAtIndexPath: indexPath];
419
- }
420
417
if (self.selectEnable ) {
421
418
return UITableViewCellEditingStyleInsert | UITableViewCellEditingStyleDelete;
422
419
}
420
+ if (DWRespond) {
421
+ return [DWDelegate dw_TableView: tableView editingStyleForRowAtIndexPath: indexPath];
422
+ }
423
423
return UITableViewCellEditingStyleNone;
424
424
}
425
425
@@ -551,14 +551,13 @@ -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)
551
551
-(UITableViewCell *)tableView : (UITableView *)tableView cellForRowAtIndexPath : (NSIndexPath *)indexPath
552
552
{
553
553
DWTableViewHelperCell * cell = nil ;
554
- DWTableViewHelperModel * model = nil ;
554
+ DWTableViewHelperModel * model = [ self modelFromIndexPath: indexPath] ;
555
555
if (DWRespond) {
556
556
cell = [DWDelegate dw_TableView: tableView cellForRowAtIndexPath: indexPath];
557
557
if (!cell) {
558
558
NSAssert (NO , @" you have implemetation the dw_TableView:cellForRowAtIndexPath delegate but pass a nil cell at indexPath of S%ld R%ld " ,indexPath.section,indexPath.row);
559
559
}
560
560
} else {
561
- model = [self modelFromIndexPath: indexPath];
562
561
cell = [self createCellFromModel: model useReuse: YES ];
563
562
}
564
563
if (self.loadDataMode == DWTableViewHelperLoadDataIgnoreHighSpeedMode) {
@@ -1251,6 +1250,9 @@ @interface DWTableViewHelperModel ()
1251
1250
// /计算的横屏行高
1252
1251
@property (nonatomic ,assign ) CGFloat calRowHeightH;
1253
1252
1253
+ // /原始cell选择样式
1254
+ @property (nonatomic ,assign ) NSInteger originalSelectionStyle;
1255
+
1254
1256
@end
1255
1257
1256
1258
@implementation DWTableViewHelperModel
@@ -1264,6 +1266,7 @@ -(instancetype)init{
1264
1266
if (!ImageNull) {
1265
1267
ImageNull = [UIImage new ];
1266
1268
}
1269
+ self.originalSelectionStyle = -1 ;
1267
1270
NSString * cellClass = NSStringFromClass ([self class ]);
1268
1271
NSArray * arr = [cellClass componentsSeparatedByString: @" Model" ];
1269
1272
if (arr.count ) {
@@ -1369,8 +1372,10 @@ -(void)layoutSubviews
1369
1372
// /适配第一次图片为空的情况
1370
1373
- (void )setEditing : (BOOL )editing animated : (BOOL )animated {
1371
1374
[super setEditing: editing animated: animated];
1372
- if (self.selectionStyle == UITableViewCellSelectionStyleNone ) {
1375
+ if (editing && self.selectionStyle != UITableViewCellSelectionStyleDefault ) {// 编辑状态下保证非无选择样式
1373
1376
self.selectionStyle = UITableViewCellSelectionStyleDefault;
1377
+ } else if (!editing && self.selectionStyle != self.model .originalSelectionStyle ) {// 退出编辑状态是恢复原始选择样式
1378
+ self.selectionStyle = self.model .originalSelectionStyle ;
1374
1379
}
1375
1380
BOOL toSetUnselectIcon = self.model .cellEditUnselectedIcon != ImageNull && self.model .cellEditUnselectedIcon != nil ;
1376
1381
for (UIControl *control in self.subviews ){
@@ -1400,6 +1405,7 @@ -(void)setupUI {
1400
1405
self.backgroundColor = [UIColor whiteColor ];
1401
1406
self.multipleSelectionBackgroundView = [UIView new ];
1402
1407
self.selectedBackgroundView = [UIView new ];
1408
+ self.selectionStyle = UITableViewCellSelectionStyleNone;
1403
1409
self.loadDataImageView = [UIImageView new ];
1404
1410
self.loadDataImageView .backgroundColor = [UIColor whiteColor ];
1405
1411
}
@@ -1411,6 +1417,9 @@ -(void)setupConstraints {
1411
1417
-(void )setModel : (__kindof DWTableViewHelperModel *)model
1412
1418
{
1413
1419
_model = model;
1420
+ if (model.originalSelectionStyle == -1 ) {// 仅在初次生成cell的时候同步cell的选择样式
1421
+ model.originalSelectionStyle = self.selectionStyle ;
1422
+ }
1414
1423
}
1415
1424
1416
1425
-(void )showLoadDataPlaceHolder : (UIImage *)image height : (CGFloat)height {
0 commit comments