5 Ocak 2011, ÇARŞAMBA
UİGestureRecognizer ve UİTableViewCell sorunu
Yani UITableViewCell
cellForRowAtIndexPath:
bir yöntem UISwipeGestureRecognizer
bir ekleme yapıyorum:
- (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];
UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipe:)];
gesture.direction = UISwipeGestureRecognizerDirectionRight;
[cell.contentView addGestureRecognizer:gesture];
[gesture release];
}
return cell;
}
Ancak, didSwipe
yöntem her zaman iki kez başarılı çekin dedi. Ben Başlangıçta bu hareketi başlar ve biter çünkü olduğunu düşündüm, ama eğer dışarı gestureRecognizer kendisi ben günlük, ikisi de "Bitti" durumu:
-(void)didSwipe:(UIGestureRecognizer *)gestureRecognizer {
NSLog(@"did swipe called %@", gestureRecognizer);
}
Konsol:
2011-01-05 12:57:43.478 App[20752:207] did swipe called <UISwipeGestureRecognizer: 0x5982fa0; state = Ended; view = <UITableViewCellContentView 0x5982c30>; target= <(action=didSwipe:, target=<RootViewController 0x5e3e080>)>; direction = right>
2011-01-05 12:57:43.480 App[20752:207] did swipe called <UISwipeGestureRecognizer: 0x5982fa0; state = Ended; view = <UITableViewCellContentView 0x5982c30>; target= <(action=didSwipe:, target=<RootViewController 0x5e3e080>)>; direction = right>
Ben gerçekten neden bilmiyorum. Belli ki sona Erdi devlet denetleme denedim, ama onlar gibi gel de bir faydası yok "Bitti" her neyse... Herhangi bir fikir?
CEVAP
5 Ocak 2011, ÇARŞAMBA
Hücreye hareket algılayıcı doğrudan eklemek yerine, viewDidLoad
tableview ekleyebilirsiniz.
didSwipe
Yöntemi aşağıdaki gibi etkilenen İndexPath ve hücre belirleyebilirsiniz
-(void)didSwipe:(UIGestureRecognizer *)gestureRecognizer {
if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
CGPoint swipeLocation = [gestureRecognizer locationInView:self.tableView];
NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:swipeLocation];
UITableViewCell* swipedCell = [self.tableView cellForRowAtIndexPath:swipedIndexPath];
// ...
}
}
Bunu Paylaş:
Otomatik düzen kısıtlamaları UİTableVi...
CocoaPods arm64 sorunu...
Youtube iframe wmode sorunu...
'transform3d' 'pozisyon...
' 'pencere' global bir ...