How to swipe gesture segue back to previous view ios?
Asked Answered
I

1

1

I'm trying to segue back to (QueryController) the view i came from. But no swipe actions occurs... Not sure what im missing.

enter image description here

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

}
Iives answered 8/1, 2014 at 5:17 Comment(3)
Use the Navigation Stack and push ViewController at the selector target of gestureLisa
Add initWithNibName code in the viewDidLoad method.Cornemuse
Thanks @Dilip et al. Putting in the viewDidLoad method fixed it. It works now.Iives
C
4

Add your UISwipeGestureRecognizer code in viewDidLoad Method..

- (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];
}
Cornemuse answered 8/1, 2014 at 6:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.