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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:35:33+00:00 2026-05-14T00:35:33+00:00

I have a UIViewController with a XIB and want to add programmatically another subview.

  • 0

I have a UIViewController with a XIB and want to add programmatically another subview.

During the initialization of the subview (initWithFrame) i want to set some attributes to values according to attributes that belong to another Object which holds data (actually a ViewControllers Child-Object, but not a view).

-(id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {

        // The following is kind of what i want
        self.myAttribute = [self.viewController.otherObject otherValue]; 
    }
    return self;

}

I want to conform to the Model-View-Controller paradigm and try to seperate my data from the subview and don’t know how to access the data from within the subview.

Thanks in advance for any answers and comments how to improve the question.

EDIT: All three answers are useful for me to understand that my design is somehow the wrong way of doing the thing. As far as i understand the subview properties should be modified by the controller instead of trying the subview making to get the information. I will accept Jasons answer for his effort explaining this to me.

  • 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-14T00:35:34+00:00Added an answer on May 14, 2026 at 12:35 am

    If you put this view in place using something like a UINavigationViewController you can use the parentViewController property. If not–and really, just in general–you can create properties that need to be set on your new view controller, and just set them in the parent or whoever else might create it.

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

Sidebar

Related Questions

I have a UIViewController view as a subview/modal on top of another UIViewController view,
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 want to set the view property of a UIViewController at runtime. I have
I have a UIViewController with its own .xib, and I want to use a
I have a UIViewController I am loading from a xib file and pushing onto
I have made a UIViewController subclass without a .xib file, thinking I would not
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
In my iPhone app I have a UIViewController that has a UITableView and another

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.