Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>[touchedView nextResponder]</code> will return the <code>UIViewController</code> object that manages <code>touchedView</code> (if it has one) or <code>touchedView</code>'s superview (if it doesn’t have a <code>UIViewController</code> object that manages it).</p> <p>For more information, see the <a href="http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIResponder_Class/Reference/Reference.html" rel="nofollow">UIResponder Class Reference</a>. (<code>UIViewController</code> and <code>UIView</code> are subclasses of <code>UIResponder</code>.)</p> <p>In your case, since you happen to know that <code>touchedView</code> is your viewController's view (and not, for instance, a subview of your viewController's view), you can just use:</p> <pre><code>TaskUIViewController *touchedController = (TaskUIViewController *)[touchedView nextResponder]; </code></pre> <p>In the more general case, you could work up the responder chain until you find an object of kind UIViewController:</p> <pre><code>id aNextResponder = [touchedView nextResponder]; while (aNextResponder != nil) { if ([aNextResponder isKindOfClass:[UIViewController class]]) { // we have found the viewController that manages touchedView, // so we break out of the while loop: break; } else { // we have yet to find the managing viewController, // so we examine the next responder in the responder chain aNextResponder = [aNextResponder nextResponder]; } } // outside the while loop. at this point aNextResponder points to // touchedView's managing viewController (or nil if it doesn't have one). UIViewController *eureka = (UIViewController *)aNextResponder; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload