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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:51:57+00:00 2026-06-17T03:51:57+00:00

How can I load separate nib files for my iPhone app that checks whether

  • 0

How can I load separate nib files for my iPhone app that checks whether the user has an iPhone 5/iPod Touch 4-inch screen versus a 3.5 inch screen?

Is this done in the init method?

Details
– I am not using a storyboard for the entire app. At one point I do use a storyboard and call it up from one of the view controllers. (is there a way to differentiate for storyboards as well?)

  • I am looking for a solution that initializes in each separate viewController… not something that I would put in the appdelegate that only runs once.

  • Autolayout doesn’t work in many situations situation for me. The designs are very graphical, and too much white space makes things look bad.

  • 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-17T03:51:58+00:00Added an answer on June 17, 2026 at 3:51 am

    I have found a way!

    • I make separate nib files, one for the 3.5″ / iPhone non retina and one for the iPhone5
    • I use a macro to check if the current phone is an iPhone 5 format or not. (1)
    • For the normal initWithNibName:bundle: I write an exception so that they don’t use the normal initializer. I name it @”Wrong initializer”
    • I created a new designated initializer for the viewController naming it initForFormat:
    • I use my macro and check against if the device is an iPhone 5 or not. if it is iphone5 then I init with the nib name ViewControllerIphone5

    Macro
    I got this macro from https://stackoverflow.com/a/13068238/1492368 from RayOfHope

     #define HEIGHT_IPHONE_5 568
    #define IS_IPHONE   ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
    #define IS_IPHONE_5 ([[UIScreen mainScreen] bounds ].size.height == HEIGHT_IPHONE_5 )
    

    so In the new designated initializer initForLayout: I write

    if(IS_IPHONE_5)
        {
            self=[super initWithNibName:@"DetailViewControlleriPhone5" bundle:nil];
        }
        else
        {
            self=[super initWithNibName:@"DetailViewController" bundle:nil];
        }
    

    Old Initializer

    I learned this from Big Nerd Ranch:
    to throw an exception when using the standard initializer

    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
    
        @throw [NSException exceptionWithName:@"Wrong initializer"
                                       reason:@"Use initForLayout:"
                                     userInfo:nil];
        return nil;
    }
    

    Calling the View Controller from another ViewController/AppDelegate
    So when I call this DetailViewController from another view Controller or the appdelegate I write:

    DetailViewController *detailViewController = [[DetailViewController alloc] initForLayout];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can load COM DLLs that are registered on my machine like this: Type
Apache Pig can load data from Hadoop sequence files using the PiggyBank SequenceFileLoader :
I have a web application that can load plugins through reflection. It currently uses
I am developing app that has multiple skins and I have a dilemma on
I'm using Google Maps to make a map that can load markers with lat/lng
I have two nib files, one that will open at startup and another that
In my programme webview is load in separate layout when button click. that layout
I've got an app that I've developed for the iPhone, but now want to
Let's say I load jQuery from a separate domain and host. Can this other
I am creating a home automation app that has allows plugin views. I have

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.