私はテーブルビューなぜ私の関数は2回呼び出されますか?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
//swipe recognition
UISwipeGestureRecognizer *g = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(cellWasSwiped:)];
[cell addGestureRecognizer:g];
[g release];
}
// Configure the cell...
[[cell textLabel] setText:[NSString stringWithFormat:@" number %d", indexPath.row]];
return cell;
}
のセルに添付スワイプ認識を持っており、スワイプ機能が
- (void)cellWasSwiped:(UIGestureRecognizer *)g {
NSLog(@"sunt in cellWasSwiped");
swipeViewController *svc = [[swipeViewController alloc]init];
[self.navigationController pushViewController:svc animated:YES];
[svc release];
}
と私は私のスワイプ機能が2回呼び出され、そこにあるされていることが分かりブレークポイントを導入することです2つの同一のビューコントローラがナビゲーションコントローラにプッシュされました。スワイプ機能を2回呼び出したのはなぜですか?
uはスワイプで一度だけ行われていることを確認してくださいましたか? – Dinakar
また、セルではなくセルのcontentViewにジェスチャを追加してみてください。 – Dinakar
あなたがそれをやっているやり方は、個々のセルごとにジェスチャ認識機能を追加することです。 tableView全体に1つだけ追加してみてください。 – Greg