Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • add touch event to UIView

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.31k
    Comment on it

    To provide some action on touch of any view ,UITapGestureRecognizer is used. Write this code in viewDidLoad

    - (void)viewDidLoad {
      [super viewDidLoad];
    
    
     myView.userInteractionEnabled = YES;
    UITapGestureRecognizer *singleFingerTap = 
      [[UITapGestureRecognizer alloc] initWithTarget:self 
                                              action:@selector(handleSingleTap:)];
    [myView addGestureRecognizer:singleFingerTap]; //myView is that view for whom we want to set any action
    [singleFingerTap release];
    
    //The event handling method
    - (void)handleSingleTap:(UITapGestureRecognizer *)recognizer {
      CGPoint location = [recognizer locationInView:[recognizer.view superview]];
    //set any action you want to perform on touch event 
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: