私のiPhone UITableビューアプリケーションで
ユーザーがテーブル ビューのセル/行をスワイプするときに 2 つのボタンを追加する必要があります。
連絡先に[SMS] ボタンを送信するための[メール作成] ボタンの 1つ。
今のところ、Send Mail (Blue Cloud Button )を追加するために次のコードを実装しました
//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
以下のように繰り返される
他のセルでスワイプをテーピングしている間、他のセルのボタンを表示(削除)したくない一度に1つのクラウドボタンのみ..