在我的iPhone UITable 视图应用程序中
当用户在表格视图单元格/行上滑动时,我需要添加两个按钮。
一个用于撰写邮件按钮,一个用于向联系人发送短信按钮。
我现在实现了以下代码来添加发送邮件(蓝色云按钮)
//Add a left swipe gesture recognizer in view Did load
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(swipeRow:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
[contactsTable addGestureRecognizer:recognizer];
[recognizer release];
- (void)swipeRow:(UISwipeGestureRecognizer *)gestureRecognizer
{
//Get location of the swipe
CGPoint location = [gestureRecognizer locationInView:contactsTable];
NSIndexPath *indexPath = [contactsTable indexPathForRowAtPoint:location];
UITableViewCell *cell = [contactsTable cellForRowAtIndexPath:indexPath];
UIButton *MailButton = [UIButton buttonWithType:UIButtonTypeCustom];
[MailButton setBackgroundImage:[UIImage imageNamed:@"sendData.png"] forState:UIControlStateNormal];
MailButton.frame=CGRectMake(150, 0, 40.0, 30.0);
[MailButton addTarget:self action:@selector(SendMail) forControlEvents:UIControlEventTouchUpInside];
//Add mail button if index path is valid
if(indexPath)
{
[cell addSubview:MailButton];
}
}
当我们在单元格上滑动时,它执行良好并将按钮添加到选定的单元格/行。
But when we swipe another cell the buttons on the previous cell are does not hide / removed
重复如下
我不想在其他单元格上显示(删除)按钮,同时在另一个单元格上轻扫,一次只有一个云按钮..