iOS 長按事件 UILongPressGestureRecognizer


//像這種控件的長按事件有些地方是有系統自帶的。但有些時候用起來也不太方便。下面這個可能以后能用到
UILongPressGestureRecognizer *longPressReger = [[UILongPressGestureRecognizer alloc]
                                                        
                                                        initWithTarget:self action:@selector(handleLongPress:)];
        
        longPressReger.minimumPressDuration = 2.0;
        
        [tbv addGestureRecognizer:longPressReger];
        
        [longPressReger release];


-(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer
{
    NSLog(@"wwwwwfffffff");
    CGPoint point = [gestureRecognizer locationInView:tbv];
    if(gestureRecognizer.state == UIGestureRecognizerStateBegan)
        
    {
        NSLog(@"ssseeeeee");
    }
    
    else if(gestureRecognizer.state == UIGestureRecognizerStateEnded)
        
    {
        NSLog(@"mimimimimimi");
    }
    
    else if(gestureRecognizer.state == UIGestureRecognizerStateChanged)
        
    {
        NSLog(@"lostllllllll");
        
    }
    
    NSIndexPath *indexPath = [tbv indexPathForRowAtPoint:point];
    
    if (indexPath == nil)
    {
        NSLog(@"sadfasdfasdf");
    }
    else
    {
        
        //focusRow = [indexPath row];
        
        //focusView.hidden = NO;
        
    }
    
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM