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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:54:03+00:00 2026-05-18T09:54:03+00:00

I have subclassed UIView and created a NIB that controls the main logic for

  • 0

I have subclassed UIView and created a NIB that controls the main logic for my application.

Hoping the view will scale nicely, I want to use it for both the iPhone and iPad versions of the app.

On the iPhone the view will cover the full screen. On the iPad the view will cover only part of the screen.

I have read that you shouldn’t use UIViewControllers to control only part of the screen. So, I am trying to embed the custom UIView in the main UIViewController’s view using IB.

How can this be done?

  • 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-18T09:54:03+00:00Added an answer on May 18, 2026 at 9:54 am

    After a lot of trial and error I found a solution based on an approach explained in the following question, answered by Brian Webster.

    The solution was originally suggested for a Cocoa environment. I hope it is valid in an iOS environment as well.

    1. Create the main view controller with a NIB-file. In the NIB, the File’s Owner should correspond to the class of your main view controller.
    2. Create a custom view controller with a NIB-file. In this NIB, the File’s Owner should correspond to the class of your custom view controller.
    3. Create a custom view controller property in your main view controller class.
    4. Create an UIView property in the main view controller class. It will hold your custom view controller’s view. Define it as an IBOutlet, so it can be linked in the NIB.
    5. Drop a UIView in your main view controller’s NIB. Link it to the main view controller’s view IBOutlet. It will be used as a placeholder for the custom view.
    6. In the main view controller’s viewDidLoad method, load the custom view controllers NIB, determine the custom view’s frame size and copy the view in the main view controller’s view.

    Here is some code:

    • MainViewController.h

      @interface MainViewController : UIViewController {
        CustomViewController *customViewController;
        UIView *customView;
      }
      @property (nonatomic, retain) CustomViewController *customViewController;
      @property (nonatomic, retain) IBOutlet UIView *customView;
      @end

    • MainViewController.m

      - (void)viewDidLoad {
        CustomViewController *controller = [[CustomViewController alloc] initWithNibName:@"CustomViewController" bundle:nil];
        self.customViewController = controller;
        [controller release];
        customViewController.view.frame = customView.frame;
        customViewController.view.autoresizingMask = customView.autoresizingMask;
        [customView removeFromSuperview];
        [self.view addSubview:customViewController.view];
        self.customView = customViewController.view;
        [super viewDidLoad];
      }
      

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

Sidebar

Related Questions

I currently have a UIView subclass that acts as my header view for my
I have subclassed UIView and provided my own drawRect, which works fine. However I
I have subclassed UIView so I can draw some lines in it. In this
I have a UIView with it's subclass set in interface builder to a UIView
In my UIViewController subclass, I have 3 UIView 's with each a @property as
So I wanted to make my UIWebview respon to touch events. I have read
I need to create an algorithm to layout some hierarchical data but have never
i was trying out quartz 2d today and i got to learn basic drawing
I'd like to generate some revenue for my OpenGL based iPhone app w/ Apple's

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.