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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:31:27+00:00 2026-05-29T05:31:27+00:00

I have a UIViewController with an xib and using Interface Builder I’ve added a

  • 0

I have a UIViewController with an xib and using Interface Builder I’ve added a child UIView.
Within the child UIView, when I click on an object within that view, I want to be able to alter the title of the whole window.

Now I’d normally do that setting

self.title = @"hi";

on the parent UIViewController. But is there any way I can access the parent title from within the child?

I’ve tried

self.superview.title = @"i";
self.parentViewController.title = @"hi";

but neither work.
Any help much appreciated

thanks

  • 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-29T05:31:27+00:00Added an answer on May 29, 2026 at 5:31 am

    self.superview.title = @"i"; evaluates to an object of type UIView, and UIView has no title property. UIViewControllers have a parentViewController property but UIViews don’t.

    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 UIControl (which things like UIButton already are, but if it’s a custom UIView subclass then you can just change it into a UIControl subclass since UIControl is itself a subclass of UIView), then in your controller add something like:

    - (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";
    }
    

    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.

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

Sidebar

Related Questions

I have a simple UIViewController that uses a XIB for its interface. As such,
I have two NIB's ParentViewController.xib ChildViewController.xib ParentViewController.xib contains a UIView and a UIViewController. ChildViewController.xib
I have a UIViewController class MyClass that initially had no XIB, and was initialized
I have added a XIB based UIViewController to my solution and dragged some UIViews
I have a UIViewController that has a XIB. I don't want to get rid
i have a tabBarController application and using .xib files for the interface not the
I have UIViewController without a xib, and I'm using loadView to build my UI
I have differents UIViewController that contains components that appear and disappear from the view
I have a view hierarchy that has a UIViewController as Files Owner in the
I have a View Controller that is swapping UIView objects in and out. There

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.