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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:43:57+00:00 2026-05-13T15:43:57+00:00

I have written a custom class that depends significantly on touch dragging/positioning, outside of

  • 0

I have written a custom class that depends significantly on touch dragging/positioning, outside of it’s own view boundaries.
There is an associated protocol defined with various relevant methods.
An example of something that would use this protocol would be a view that allows things to be dropped into it from my custom class.

The problem I have is in figuring out when a touch is ended (the object is ‘dropped’), whether or not there is an object that cares below that position. (For ‘cares’, read ‘conforms to the protocol’!).

If it’s a view that conforms to my protocol, it’s easy, I can find it with - (CALayer *)hitTest:(CGPoint)thePoint or something along those lines and query with a conformsToProtocol:@protocol(xx).

But if it is a view which is a subview of a UIViewController (for example), the view does not conform to the protocol, even though the UIViewController (as it’s delegate) does.
If the view really does want to be notified, I need to be able to figure out who it’s delegate is, to message.

So, essentially, how do I traverse up the view hierarchy from the lowest UIView, asking if each view conforms to my protocol; and if it doesn’t, does it have a delegate, and does that conform..?

Or is there a much easier way I haven’t thought of?

Thanks very much..


Solved

Thanks to moshy, I’ve got a solution:

- (UIView *)viewThatConformsToProtocol:(Protocol *)protocol AtPointInWindow:(CGPoint)point {
   UIView *lowestUIView = [[(AppDelegate).navigationController view] hitTest:point withEvent:nil];
   UIResponder *respondsToProtocol = lowestUIView;
   while ((respondsToProtocol != nil) && (![respondsToProtocol conformsToProtocol:protocol])) {
      respondsToProtocol = [respondsToProtocol nextResponder]; // else try the next responder up the chain
   };
   return (UIView *)respondsToProtocol;
}

This either returns the view, or nil if nothing conforms.

Thanks again..

  • 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-13T15:43:57+00:00Added an answer on May 13, 2026 at 3:43 pm

    Well, once you have the lowest view, you could walk up the responder chain using - (UIResponder *)nextResponder.

    From the docs:

    The UIResponder class does not store
    or set the next responder
    automatically, instead returning nil
    by default. Subclasses must override
    this method to set the next responder.
    UIView implements this method by
    returning the UIViewController object
    that manages it (if it has one) or its
    superview (if it doesn’t);
    UIViewController implements the method
    by returning its view’s superview;
    UIWindow returns the application
    object, and UIApplication returns nil.

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

Sidebar

Related Questions

I have written a custom SessionStoreProvider class that inherits from the SessionStateStoreProviderBase. I have
I have written a ListActivity class that uses a custom ArrayAdapter and Holders. I
I have written a JSP custom tag, implemented in a class that extends TagSupport,
I have a custom class that I've written that extends ImageView (for Android Java).
I have written a custom server control which (pseudo-code) looks like public class MyCustomCtrl
I have written a class in python that implements __str__(self) but when I use
I have a class library that I have written in C#.net. I want to
I have written a custom MSBuild task, call it TaskA, that parses a file
I have written an abstract class that I am using to automate a lot
I have written a custom credit card validation attribute that checks CardNumber property is

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.