user2470111
user2470111

Reputation: 43

Call Gesture Method Programmatically

I am working on application where i need to call single tap gesture method without touch or swipe anything.I want to call that method when initWithframe method call.I just want to call this method programmatically only once.Please help me.How can i do this?thanking you.

Upvotes: 1

Views: 2199

Answers (2)

Rajan Twanabashu
Rajan Twanabashu

Reputation: 4726

    UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] init];
    gesture.direction = UISwipeGestureRecognizerDirectionLeft;
    [self handleSwipe:gesture];

Upvotes: 0

Lithu T.V
Lithu T.V

Reputation: 20021

Try this

    UITapGestureRecognizer * recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
    recognizer.delegate = self;
    [view addGestureRecognizer:recognizer];

and the method

- (void)handleTap:(UITapGestureRecognizer *)recognizer {    
}

To do it programatically.Why you need to manipulate tap.Just call the method directly.To call method use

[self handleTap:nil];

Upvotes: 2

Related Questions