简体   繁体   English

如何在iOS SDK中的TableView中向左和向右滑动

[英]how to left and right swipe in tableview in iOS sdk

I want to make a tableview in which i want jobs will change to swipe left and right . 我要创建一个表格视图,在该表格中我希望作业将更改为左右滑动。 By default in iphone swipe is for delete,so how can i make this. 在iPhone中,默认情况下刷卡是删除,所以我该如何做。 i used gesture for that, but it does not look any transition in tableview,just swipe only,I want swipe transition will show like we are swapping. 我为此使用了手势,但它在tableview中看起来没有任何过渡,仅滑动即可,我希望滑动过渡将显示出我们正在交换的效果。

Please help ! 请帮忙 !

Method For Left Swipe 左挥动方法

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

Method For Right Swipe 右滑动方法

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

left Swipe Action Method 向左滑动动作方法

-(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];

  }

Right Swipe Action Method 右滑动动作方法

-(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];

  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM