Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9055427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:57:06+00:00 2026-06-16T13:57:06+00:00

So I have a method then when called generates a simple UIView with some

  • 0

So I have a method then when called generates a simple UIView with some labels in it:

UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 300, 250)];
view1.backgroundColor = [UIColor redColor];
view1.userInteractionEnabled = YES;
[self.view addSubview:view1];

I call this method 6 times so it places 6 UIViews (I give them different coordinates of course) around the screen.

How can I detect when a user swipes right on one of them and then trigger some other method?
I’ve tried something like this:

UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(myLabel1Tap)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[view1 addGestureRecognizer:swipeRight];

and then a method:

- (void)myLabel1Tap {
}

But I’m not sure what to do inside that method, how can I know which view was swiped if they are all called the same ‘view1’?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T13:57:07+00:00Added an answer on June 16, 2026 at 1:57 pm

    change the gesture recognizers selector to accept an argument (by adding a colon after the method signature)

    UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(myLabel1Swipe:)];
    

    this will mean the gesture recognizer will get passed in, and then you can perform actions based on the gesture recognizers properties, e.g.

    - (void)myLabel1Swipe:(UISwipeGestureRecognizer *)recogniser
    {
        UIView *swipedView = [recognizer view];
        //do whatever you want with this view
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a js script which declares a namespace, then has a method called
From my website, I have a button which calls a method and then generates
I have a method which animates one of the subviews of UIWindow and then
I have a method that looks for the word 'not' and then a word
I have a service method that calls a DAO which then returns an object
I have a WCF service method that expects an object and then retrieves its
I have a base class called Entity which has a static method called construct
I have a controller with a method which returns a partial view and generates
I have created a simple web service called TimeServerBean . It's working properly, the
I have method that returns Drawable , and if its Bitmap object is recycled

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.