1
This commit is contained in:
@@ -82,30 +82,39 @@
|
||||
}
|
||||
|
||||
/// 左滑删除
|
||||
- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) {
|
||||
|
||||
__weak typeof(self) weakSelf = self;
|
||||
|
||||
// 删除按钮
|
||||
UIContextualAction *deleteAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
|
||||
title:nil
|
||||
handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
|
||||
[weakSelf deleteItemAtIndexPath:indexPath];
|
||||
completionHandler(YES);
|
||||
}];
|
||||
deleteAction.backgroundColor = [UIColor colorWithHex:0xF44336];
|
||||
if (@available(iOS 13.0, *)) {
|
||||
deleteAction.image = [UIImage systemImageNamed:@"trash.fill"];
|
||||
}
|
||||
|
||||
UISwipeActionsConfiguration *config = [UISwipeActionsConfiguration configurationWithActions:@[deleteAction]];
|
||||
config.performsFirstActionWithFullSwipe = NO;
|
||||
return config;
|
||||
}
|
||||
//- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) {
|
||||
//
|
||||
// NSLog(@"[KBAIMessageListVC] trailingSwipeActionsConfigurationForRowAtIndexPath called for row: %ld", (long)indexPath.row);
|
||||
//
|
||||
// __weak typeof(self) weakSelf = self;
|
||||
//
|
||||
// // 删除按钮
|
||||
// UIContextualAction *deleteAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
|
||||
// title:nil
|
||||
// handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
|
||||
// NSLog(@"[KBAIMessageListVC] Delete action triggered for row: %ld", (long)indexPath.row);
|
||||
// [weakSelf deleteItemAtIndexPath:indexPath];
|
||||
// completionHandler(YES);
|
||||
// }];
|
||||
// deleteAction.backgroundColor = [UIColor colorWithHex:0xF44336];
|
||||
// if (@available(iOS 13.0, *)) {
|
||||
// deleteAction.image = [UIImage systemImageNamed:@"trash.fill"];
|
||||
// }
|
||||
//
|
||||
// UISwipeActionsConfiguration *config = [UISwipeActionsConfiguration configurationWithActions:@[deleteAction]];
|
||||
// config.performsFirstActionWithFullSwipe = NO;
|
||||
// return config;
|
||||
//}
|
||||
|
||||
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
return YES;
|
||||
}
|
||||
//- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
// NSLog(@"[KBAIMessageListVC] canEditRowAtIndexPath called for row: %ld", (long)indexPath.row);
|
||||
// return YES;
|
||||
//}
|
||||
|
||||
//- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
// NSLog(@"[KBAIMessageListVC] editingStyleForRowAtIndexPath called for row: %ld", (long)indexPath.row);
|
||||
// return UITableViewCellEditingStyleDelete;
|
||||
//}
|
||||
|
||||
#pragma mark - JXCategoryListContentViewDelegate
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
make.left.equalTo(self.kb_backButton.mas_right).offset(0);
|
||||
make.centerY.equalTo(self.kb_backButton);
|
||||
make.height.mas_equalTo(44);
|
||||
make.width.mas_equalTo(180);
|
||||
make.width.mas_equalTo(250);
|
||||
}];
|
||||
|
||||
// 添加搜索按钮
|
||||
@@ -74,6 +74,10 @@
|
||||
|
||||
// 关联 categoryView 和 listContainerView
|
||||
self.categoryView.listContainer = self.listContainerView;
|
||||
|
||||
// 初始状态:默认选中第一个 tab (Thumbs Up),允许左右滑动切换
|
||||
// self.listContainerView.scrollView.scrollEnabled = YES;
|
||||
self.navigationController.interactivePopGestureRecognizer.enabled = (self.categoryView.selectedIndex == 0);
|
||||
}
|
||||
|
||||
#pragma mark - 2:绑定事件
|
||||
@@ -151,6 +155,14 @@
|
||||
if (!_listContainerView) {
|
||||
_listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
|
||||
_listContainerView.scrollView.bounces = NO;
|
||||
// _listContainerView.scrollView.scrollEnabled = false;
|
||||
|
||||
// 不延迟触摸事件,让手势能更快响应
|
||||
// for (UIGestureRecognizer *gestureRecognizer in _listContainerView.scrollView.gestureRecognizers) {
|
||||
// if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
|
||||
// gestureRecognizer.delaysTouchesBegan = NO;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
return _listContainerView;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,17 @@
|
||||
[super viewDidLoad];
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDelegate Override
|
||||
|
||||
// Thumbs Up tab 不需要左滑删除功能
|
||||
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
return NO; // 禁用左滑删除
|
||||
}
|
||||
|
||||
- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) {
|
||||
return nil; // 不显示滑动操作
|
||||
}
|
||||
|
||||
#pragma mark - 2:数据加载
|
||||
|
||||
- (void)loadData {
|
||||
|
||||
Reference in New Issue
Block a user