Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>self.superview.title = @"i";</code> evaluates to an object of type <code>UIView</code>, and <code>UIView</code> has no <code>title</code> property. <code>UIViewController</code>s have a <code>parentViewController</code> property but <code>UIView</code>s don't.</p> <p>So the fundamental problem is that you're not properly separating your controller and your view classes. What you'd normally do is make the view you want to catch taps on a subclass of <code>UIControl</code> (which things like <code>UIButton</code> already are, but if it's a custom <code>UIView</code> subclass then you can just change it into a <code>UIControl</code> subclass since <code>UIControl</code> is itself a subclass of <code>UIView</code>), then in your controller add something like:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; // we'll want to know if the view we care about is tapped; // we've probably set up an IBOutlet to it but any way of // getting to it is fine [interestingView addTarget:self action:@selector(viewTapped:) forControlEvents:UIControlEventTouchDown]; // UIButtons use UIControlEventTouchUpInside rather than // touch down if wired up in the interface builder. Pick // one based on the sort of interaction you want } // so now this is exactly like an IBAction - (void)viewTapped:(id)sender { self.title = @"My new title"; } </code></pre> <p>So you explicitly don't invest the view with any knowledge about its position within the view hierarchy or how your view controllers intend to act. You just tell it to give you a shout out if it receives a user interaction.</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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