2014-11-05 77 views
0

我想做一個tableview,其中我想作業將更改左右滑動。 默認情況下在iPhone刷卡是刪除,所以我怎麼做到這一點。 我使用過這種手勢,但它在tableview中看起來沒有任何轉換,只需滑動即可,我想要滑動轉換將顯示爲我們正在交換。如何左右滑動在iOS中的桌面視圖sdk

請幫忙!

回答

2

方法向左掃

UISwipeGestureRecognizer * swipeleft=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeleft:)]; 
swipeleft.direction=UISwipeGestureRecognizerDirectionLeft; 
[yourtableviewName addGestureRecognizer:swipeleft]; 

方法向右滑動

UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] 
            initWithTarget:self action:@selector(swiperight:)]; 
[gesture setDirection:UISwipeGestureRecognizerDirectionRight]; 
[tblvie addGestureRecognizer:gesture]; 

向左掃動作方法

-(void)swipeleft:(UISwipeGestureRecognizer*)recognizer 
{ 
    int tag = (int)recognizer.view.tag; // assign the tag if u need 
    if (tag==40) 

    { 
     // call the another function 

    } 
    else 
    { 
     // call the some another function 
    } 
    [yourtableview reloadData]; 

    } 

向右滑動操作方法

-(void)swiperight:(UISwipeGestureRecognizer*)recognizer 
{ 
    int tag = (int)recognizer.view.tag; // assign the tag if u need 
    if (tag==40) 

    { 
     // call the another function 

    } 
    else 
    { 
     // call the some another function 
    } 
    [yourtableview reloadData]; 

    } 
+0

如果u需要任何幫助,我用U當然希望 – 2014-11-05 06:06:30

+0

THanku庵埠,但我用這個代碼,但我絕對不想轉變,因爲tableview中是不是看起來swap..but它交換編程我們應該如何看待從左到右的過渡 – Jason 2014-11-05 06:40:46

+0

哦,那麼你需要就像Sefi發佈的答案 – 2014-11-05 06:45:10