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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:59:30+00:00 2026-06-04T08:59:30+00:00

I have a UIViewController (controller1) which is displaying some UIbuttons on a UIView. When

  • 0

I have a UIViewController (controller1) which is displaying some UIbuttons on a UIView. When one of the buttons is clicked I’d like to instantiate a second UIViewController (controller2, which is of an entirely different controller class) which will then create some UIViews programmatically and add these to one of the UIViews being managed by controller1.

So, in controller1 I’d like the following code:

- (void) someButtonPressed: (id)sender
{
    ViewController2* controller2 = [ [ ViewController2 alloc ] initWithNibName:nil bundle:nil ];
}

I’d then like to programmatically create the additional UIViews within controller2. Ideally I will not have any further lines of code within controller1 (to add views and suchlike). I’d really like to create all views and add them to the existing views from within the controller2 code.

Can I do this, and how? I’ve tried simply placing the following code in controller2:

- (void)loadView
{

    NSLog(@"HPSViewEditorViewController loadView");

}

but it does not get called.

I want to encapsulate the entire UIView hierarchy for controller2 in the controller2 code, and don’t want to ‘clutter up’ controller1 with anything other than the controller2 instantiation.

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-06-04T08:59:31+00:00Added an answer on June 4, 2026 at 8:59 am

    I would try something like

    [viewController1 presentModalViewController:viewController2 animated:YES];
    

    This could do the trick…

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

Sidebar

Related Questions

I have a UIViewController class and a second which I want to push modally
I have custom control like tabbar which displays many controllers some of them also
I have a UIViewController and I'm navigating from my first view controller to second
I have a UIViewController (which sits inside a tabUIController). Within this UIViewController, I want
I have a UIViewController which supports all interface Orientations. The views are created programatically
I have a UIViewController which presents a modal view controller and when I rotate
I have a very simple scenario: My iPhone application contains a UIViewController implementation which
I have a view controller which contains a UISearchBar @interface TradeFindHeaderViewController_iPhone : UIViewController {
I have a UIViewController that manages the display of some data. When the user
I have a UIViewController which uses the UITableViewDelegate and UITableViewDataSource. I have created UITableView

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.