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

  • SEARCH
  • Home
  • 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 7660881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:31:30+00:00 2026-05-31T13:31:30+00:00

I have code as the following: – (void)setPosts:(NSArray *)posts { _posts = posts; int

  • 0

I have code as the following:

- (void)setPosts:(NSArray *)posts
{
    _posts = posts;


    int totalHeight = 0;
    for (TumblrPost *post in posts) {
        totalHeight += post.thumbH;
    }
dispatch_queue_t mainQ = dispatch_get_main_queue();
dispatch_async(mainQ, ^{
    int cumulativeY = 0;
    int postCount = 0;
    for (TumblrPost *post in posts) {
        NSArray* array = [[NSBundle mainBundle] loadNibNamed:@"ThumbnailView" owner:nil options:nil];            
        ThumbnailView* thumbnail = [array objectAtIndex:0];
        thumbnail.frame = CGRectMake(0,cumulativeY,0,0);
        thumbnail.userInteractionEnabled = YES;

        UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showMainImage:)];
        [thumbnail addGestureRecognizer:gesture];

        [self.multiThumbnailView addSubview:thumbnail];
        [thumbnail loadUrl:post.url];   

        cumulativeY+=100;//post.thumbH;
        if(postCount >=2)
            break;
        postCount++;
    }
    NSLog(@"Set posts method");
});
}

- (void)showMainImage:(UITapGestureRecognizer *)gesture
{
    if(gesture.state == UIGestureRecognizerStateChanged || gesture.state == UIGestureRecognizerStateEnded)
    {
        int thumbIndex = [self.multiThumbnailView.subviews indexOfObject:gesture.view];
        self.selectedPost = (TumblrPost*)[self.posts objectAtIndex:thumbIndex];

        [self performSegueWithIdentifier:@"ShowMainPost" sender:self];
    }
}

multiThumbnailView is a UIView which I have in my storyboard and ThumbnailView is an xib/class combination which is a 100×100 square with a label in it that says ‘test’.

When I run my code I get three boxes in a vertical line but the gesture recogniser doesn’t fire when I click on my sub views. Everything has userInteractionEnabled ticked. I tried making a test gesturerecognizer on the main multiThumbnailView and that worked.

Please help!

  • 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-05-31T13:31:31+00:00Added an answer on May 31, 2026 at 1:31 pm

    My guess is that ThumbnailView is a subclass of UIImageView – which by default sets its userInteractionEnabled to NO.

    Make sure that you set userInteractionEnabled = YES on every ThumbnailViewthat you want to intercept taps.

    EDIT:

    In addition, you set the frame of the ThumbnailView to be with size of (0,0).
    That means that this view is basically invisible and thus won’t intercept touches.

    And finally, please don’t do:

    ThumbnailView* thumbnail = [array objectAtIndex:0];
    

    Instead you can check the count of the array or simply:

    ThumbnailView* thumbnail = [array lastObject];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following code: typedef int (*t_Function) (int x); t_Function Functions[MAX_FUNCTIONS]; int f(int x)
In Ado.NET world, I could have code like following Void SomeMethod(bool flag) { String
I have following code to play small audio files private void playVoice() { if
I have following code NSArray *myArray = [[NSArray alloc] initWithObjects:@1,@2,nil]; NSMutableDictionary *dic0 = [[NSMutableDictionary
I have code like following: switch(sort.Column) { case code: model = (sort.Direction == SortDirection.Ascending)
I have following Code Block Which I tried to optimize in the Optimized section
I have following code in my application: // to set tip - photo in
I have following code in my Application. Comments in my code will specify My
I have following code in my application. [self.navigationController pushViewController:x animated:YES]; It will push a

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.