-1
A
回答
0
不要这样,
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
UIAlertView *Alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Are you sure to commit with its action" delegate:self cancelButtonTitle:CKString(@"NO") otherButtonTitles:CKString(@"YES"),nil];
[Alert show];
Alert.tag=indexPath.row+1;
Alert.delegate=self;
[Alert release];
return UITableViewCellAccessoryNone;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
}
在AlertView代表
-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
int indexPathRow=alertView.tag-1;
if(buttonIndex==1)
{
//// Yes condition
} else {
///// No condition
}
}
2
您可以添加gestureRecognizer到您的
UISwipeGestureRecognizer *recognizer =[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(removeCell:)];
recognizer.direction = UISwipeGestureRecognizerDirectionRight;
[cell addGestureRecognizer:recognizer];
[recognizer release];
,然后在removeCell方法
- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer
{
UITableViewCell *cell = (UITableViewCell*)[recognizer view];
NSIndexPath* pathOfTheCell = [viewListTable indexPathForCell:cell];
NSInteger rowOfTheCell = [pathOfTheCell row];
NSInteger sectionOftheCell = [pathOfTheCell section];
UIAlertView *confirmationAlert = [[UIAlertView alloc]initWithTitle:@"Confirm" message:@"Are you sure you want to Delete this list?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Delete", nil];
[confirmationAlert show];
confirmationAlert.delegate = self;
[confirmationAlert release];
}
0
添加UISwipeGestureRecognizer
到Cell
UISwipeGestureRecognizer *gesture;
gesture = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)] autorelease];
gesture.direction = UISwipeGestureRecognizerDirectionLeft;
[cell addGestureRecognizer:gesture];
gesture = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)] autorelease];
gesture.direction = UISwipeGestureRecognizerDirectionRight;
[cell addGestureRecognizer:gesture];
而且里面的确认选择方法的提示删除
- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer
{
//Use recognizer.direction to check left/right swipe if needed
//Prompt Alert
CGPoint location = [recognizer locationInView:tableView];
NSIndexPath *swipedIndexPath = [tableView indexPathForRowAtPoint:location];
UITableViewCell *swipedCell = [tableView cellForRowAtIndexPath:swipedIndexPath];
}
+0
我需要能够访问单元格的indexPath。 – ranjha 2013-02-27 04:55:54
+0
请看最新的答案 – 2013-02-27 05:06:19
0
在Alertview委托
if (alertView.tag == index)
{
if (buttonIndex == 1)
{
[yourArray removeObjectAtIndex:alertView.tag-1];
[yourTable reloadData];
}
}
相关问题
- 1. Unslide删除按钮的UITableViewCell
- 2. UITableViewCell,删除按钮框架?
- 3. TTLauncherView删除删除按钮
- 4. 单击自定义删除按钮时删除UITableViewCell
- 5. 如何在编辑UITableViewCell时删除删除按钮?
- 6. 删除按钮不会出现在UITableViewCell
- 7. UITableViewCell的自定义删除按钮
- 8. 如何从UITableViewCell中删除按钮?
- 9. 如何显示左删除按钮UITableViewCell
- 10. UITableViewCell删除按钮不出现
- 11. 将“删除”按钮添加到UITableViewCell
- 12. 更改默认删除按钮UITableViewCell
- 13. UITableViewCell的删除按钮动画
- 14. 向UiTableViewCell添加一个删除按钮
- 15. 删除按钮
- 16. 删除按钮
- 17. 删除按钮
- 18. 删除按钮
- 19. 删除按钮
- 20. 删除按钮
- 21. moveRowAtIndexPath无删除按钮
- 22. 删除按钮,删除数据库行
- 23. 删除按钮,删除多个控件
- 24. 删除ListView元素删除按钮
- 25. Javascript按钮删除
- 26. cakephp删除按钮
- 27. Extjs,删除按钮
- 28. 删除jQuery按钮
- 29. Android删除按钮
- 30. PHP删除按钮
仍然有同样的问题,我该如何访问indexPath删除alertView委托中的行? – ranjha 2013-02-27 04:52:47
看到所有人都告诉我添加GestureRecognizer。 – ranjha 2013-02-27 04:55:12
不便之处...... – Venkat 2013-02-27 04:57:26