SORU
13 EKİM 2010, ÇARŞAMBA


UİTableView uzun basın

UITableViewCell Baskı üzerinde uzun bir basın işlemek istiyorum "hızlı erişim menü". Birileri bunu yaptı?

Özellikle jest UITableView tanıdınız mı?

CEVAP
13 EKİM 2010, ÇARŞAMBA


İlk eklemek için uzun basın jest tablo görünümüne algılayıcı:

UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] 
  initWithTarget:self action:@selector(handleLongPress:)];
lpgr.minimumPressDuration = 2.0; //seconds
lpgr.delegate = self;
[self.myTableView addGestureRecognizer:lpgr];
[lpgr release];

Hareketi işleyicisi sonra:

-(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer
{
    CGPoint p = [gestureRecognizer locationInView:self.myTableView];

    NSIndexPath *indexPath = [self.myTableView indexPathForRowAtPoint:p];
    if (indexPath == nil) {
        NSLog(@"long press on table view but not on a row");
    } else if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
        NSLog(@"long press on table view at row %d", indexPath.row);
    } else {
        NSLog(@"gestureRecognizer.state = %d", gestureRecognizer.state);
    }
}

Hücre kullanıcının normal dokunarak engel değildir, ve aynı zamanda handleLongPress kullanıcı parmağını oynatamaz önce birden çok kez ateş unutmayın ki bu dikkatli olmak zorunda.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • FPSRussia

    FPSRussia

    19 NİSAN 2010
  • Gavin Hoey

    Gavin Hoey

    21 Aralık 2007
  • Microsoft Research

    Microsoft Re

    24 EKİM 2008