本文介绍了如何将手势段切换回之前的查看iOS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正试图分割回(QueryController)我所来自的视图。但没有发生划线动作。不确定我遗漏了什么。
@implementation ProfileController4
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
UISwipeGestureRecognizer * Swiperight=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swiperight:)];
Swiperight.direction=UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:Swiperight];
UISwipeGestureRecognizer * Swipeleft=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeleft:)];
Swipeleft.direction=UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:Swipeleft];
}
return self;
}
-(void)swipeleft:(UISwipeGestureRecognizer*)gestureRecognizer
{
//Do what you want here
}
-(void)swiperight:(UISwipeGestureRecognizer*)gestureRecognizer
{
//Do what you want here
[self performSegueWithIdentifier: @"friendsBackToQuerySeg" sender: self];
// [[UIViewController alloc] initWithNibName:@"QueryController1" bundle:nil];
}
推荐答案
将UISwipeGestureRecognizer
代码添加到viewDidLoad
方法中..
- (void)viewDidLoad
{
[super viewDidLoad];
UISwipeGestureRecognizer * Swiperight=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swiperight:)];
Swiperight.direction=UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:Swiperight];
UISwipeGestureRecognizer * Swipeleft=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeleft:)];
Swipeleft.direction=UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:Swipeleft];
}
这篇关于如何将手势段切换回之前的查看iOS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!