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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:08:05+00:00 2026-05-26T07:08:05+00:00

I have a custom UIViewController whose UIView takes up a corner of the screen,

  • 0

I have a custom UIViewController whose UIView takes up a corner of the screen, but most of it is transparent except for the parts of it that have some buttons and stuff on it. Due to the layout of the objects on that view, the view’s frame can cover up some buttons beneath it. I want to be able to ignore any touches on that view if they aren’t touching anything important on it, but I seem to only be able to pass along actual touch events (touchesEnded/nextResponder stuff). If I have a UIButton or something like that which doesnt use touchesEnded, how do I pass the touch event along to that?

I can’t just manually figure out button selector to call, because this custom ViewController can be used on many different views. I basically need a way to call this:

[self.nextResponder touchesEnded:touches withEvent:event];

on UIControl types as well.

  • 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-26T07:08:06+00:00Added an answer on May 26, 2026 at 7:08 am

    Probably the best way to do this is to override hitTest:withEvent: in the view that you want to be ignoring touches. Depending on the complexity of your view hierarchy, there are a couple of easy ways to do this.

    If you have a reference to the view underneath the view to ignore:

    - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
    {
        UIView *hitView = [super hitTest:point withEvent:event];
    
        // If the hitView is THIS view, return the view that you want to receive the touch instead:
        if (hitView == self) {
            return otherView;
        }
        // Else return the hitView (as it could be one of this view's buttons):
        return hitView;
    }
    

    If you don’t have a reference to the view:

    - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
    {
        UIView *hitView = [super hitTest:point withEvent:event];
    
        // If the hitView is THIS view, return nil and allow hitTest:withEvent: to
        // continue traversing the hierarchy to find the underlying view.
        if (hitView == self) {
            return nil;
        }
        // Else return the hitView (as it could be one of this view's buttons):
        return hitView;
    }
    

    I would recommend the first approach as being the most robust (if it’s possible to obtain a reference to the underlying view).

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

Sidebar

Related Questions

I have a zooming UIScrollView that contains a UIView which contains some custom UIViews
I have a custom UIViewController, which is the only subView of UIView. The UIViewController
I have a UIViewController whose view has a custom subview. This custom subview needs
In a custom UIViewController , if I have a member UINavigationController that I initialize
I have a custom UIView subclass without a corresponding UIViewController. I use this class
On my UIViewController I have different UIViews, and some of them are my custom
I have an custom UIVIewController that is the base class for other controllers and
I have a custom UIView which gets loaded through a NIB inside a UIViewController.
I have a View that has a UIWebView, and an OptionsPane (Custom UIViewController with
In my iPhone app, I have a custom UIViewController class setup which adds some

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.