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 6351007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:55:12+00:00 2026-05-24T21:55:12+00:00

I trying to figure out how to solve this (fairly) simple problem but I

  • 0

I trying to figure out how to solve this (fairly) simple problem but I failing miserably, so I really need your advice.

My application consists of a uitabbar with several tabs. In one of them I have a bunch of UIImageViews each of which represents the thumbnail of a picture. Similarly as you remove apps from the iPhone by pressing for a second on the app icon, I implemented a UILongPressGestureRecognizer recognizer which starts wobbling the thumb. If the user taps on the ‘X’ that appears on the corner of the thumb the picture gets removed.

The logic that starts and stops the wobbling animation is inside a subclass of UIImageView that is used to show the thumb.

What I’m trying to do is cancel the wobble effect if the user presses anywhere else outside the thumb. Ideally, if possible, I would prefer to place the code that detects this cancel touch inside the UIImageView subclass.

  • 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-24T21:55:13+00:00Added an answer on May 24, 2026 at 9:55 pm

    To catch all touch events globally I ended up subclassing UIWindow as follows:

    //  CustomUIWindow.h
    #import <UIKit/UIKit.h>
    
    #define kTouchPhaseBeganCustomNotification @"TouchPhaseBeganCustomNotification"
    
    @interface CustomUIWindow : UIWindow
    @property (nonatomic, assign) BOOL enableTouchNotifications;
    @end
    
    //  CustomUIWindow.m
    #import "CustomUIWindow.h"
    
    @implementation CustomUIWindow
    
    @synthesize enableTouchNotifications = enableTouchNotifications_;
    
    - (void)sendEvent:(UIEvent *)event
    {
        [super sendEvent:event];  // Apple says you must always call this!
    
        if (self.enableTouchNotification) {
            [[NSNotificationCenter defaultCenter] postNotificationName:kTouchPhaseBeganCustomNotification object:event];
        }
    }@end
    

    Then whenever I need to start listening to all touches globally I do the following:

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(stopThumbnailWobble:)
                                                 name:kTouchPhaseBeganCustomNotification
                                               object:nil];
    
    ((CustomUIWindow *)self.window).enableTouchNotification = YES;   
    

    In stopThumbnailWobble I remove the observer and process the UITouch event to decide whether to remove the thumb or not:

    - (void)stopThumbnailWobble:(NSNotification *)event
    {    
        [[NSNotificationCenter defaultCenter] removeObserver:self 
                                                        name:kTouchPhaseBeganCustomNotification 
                                                      object:nil];
        ((CustomUIWindow *)self.window).enableTouchNotification = NO;
    
        UIEvent *touchEvent = event.object;
        // process touchEvent and decide what to do
        ...
    

    Hope this helps others.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to solve a fairly easy problem but can't quite figure out
So I'm trying to figure out the best way to solve simple logarithms using
I've been trying to figure this problem out for the last 2 days already,
Trying to figure out the best way to do this: Should I do something
Trying to figure out this pseudo code. The following is assumed.... I can only
I'm trying to figure out if this is relatively well-performing T-SQL (this is SQL
I'm trying to figure out how to solve the privilege acquisition. The application requires
I have been trying to solve this problem the whole day: How do I
I'm trying to figure out how to solve some challenges that my team is
I've been having troubles trying to figure out how to solve a function. I've

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.