Iphone 向左滑动以进行删除和编辑,删除
我找不到解决这个问题的办法。是否可以使用左扫和“编辑和删除”来设置删除选项 我在导航栏的左边有一个编辑按钮Iphone 向左滑动以进行删除和编辑,删除,iphone,objective-c,xcode,uitableview,Iphone,Objective C,Xcode,Uitableview,我找不到解决这个问题的办法。是否可以使用左扫和“编辑和删除”来设置删除选项 我在导航栏的左边有一个编辑按钮 self.navigationItem.leftBarButtonItem = self.editButtonItem; 和提交方式方法如下所示 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:
self.navigationItem.leftBarButtonItem = self.editButtonItem;
和提交方式方法如下所示
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//delete code here
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
}
}
使用此选项后,根本检测不到左扫。删除的唯一方法似乎是进入编辑模式并从中删除。
我们将不胜感激
我是个新手,所以请对我放松:)
一旦您在代理中写入上述方法,您将能够使用滑动手势。。。。在这个方法中,您将处理要执行的后续操作
谢谢
一旦您在代理中写入上述方法,您将能够使用滑动手势。。。。在这个方法中,您将处理要执行的后续操作
谢谢….请确保您已实现以下所有学员
tableView:commitEditingStyle:forRowAtIndexPath:
tableView:canEditRowAtIndexPath:
tableView:editingStyleForRowAtIndexPath
:确保您已实现以下所有委托
tableView:commitEditingStyle:forRowAtIndexPath:
tableView:canEditRowAtIndexPath:
tableView:editingStyleForRowAtIndexPath
:您的意思是在需要删除选项的单元格上滑动 如果是,您可以尝试以下代码:
- (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleDelete;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
//perform delete operation
}
您的意思是在单元格上滑动,您需要删除选项 如果是,您可以尝试以下代码:
- (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleDelete;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
//perform delete operation
}
对除了在你发布的内容中没有删除代码外,还有什么问题。现在根本没有检测到左扫。我可以通过进入编辑模式并在那里删除来删除..但不使用左扫:(顺便说一句:如果您不使用UINavigationController,您应该只使用导航栏左侧的编辑按钮。无论哪种方式,始终最好遵循指南并将编辑按钮放置在导航栏的右侧Navbar@amandir我在右边有一个“添加”按钮。是的。除了你发布的内容中没有删除代码之外,还有什么问题。现在根本没有检测到左扫。我可以通过进入编辑模式并在那里删除来删除。但不使用左扫:(顺便说一句:如果您不使用UINavigationController,您应该只使用导航栏左侧的编辑按钮。无论哪种方式,始终最好遵循指南并将编辑按钮放置在导航栏的右侧Navbar@amandir我在右边有一个添加按钮。没有。根本没有检测到向左滑动。UISweepGestureRecognizer*tempGestureRecognizer=[[self.tableView gestureRecognizers]objectAtIndex:2];tempGestureRecognizer.direction=UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight;否..完全未检测到左扫。UISwipeGestureRecognizer*tempGestureRecognizer=[[self.tableView gestureRecognizers]objectAtIndex:2];tempGestureRecognizer.direction=UISWEEgestureRecognizerDirectionLeft | UISWEEgestureRecognizerDirectionRight;是,我实现了,还连接了数据源和委托,不工作是,我实现了,还连接了数据源和委托,不工作