我要创建一个表格视图,在该表格中我希望作业将更改为左右滑动。
在iPhone中,默认情况下,刷卡是删除操作,所以我该怎么做。
我为此使用了手势,但它在tableview中看起来没有任何过渡,仅滑动即可,我希望滑动过渡将显示出我们正在交换的效果。
请帮忙 !
最佳答案
左挥动方法
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];
}