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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:42:39+00:00 2026-05-20T10:42:39+00:00

If I have a universal app (runs on both iPhone & iPad), how do

  • 0

If I have a universal app (runs on both iPhone & iPad), how do I account for UI layout differences in code if the UI differs between the devices?

If I am using a XIB, I can simply load a different XIB depending on the device and use the same code. Correct?

If I am creating my UI programmatically, though, how should this be handled? Is there a better way than if/elsing my way through the code and looking at the device type? I understand it’s doable this way, it just doesn’t seem very elegant.

if (isiPhone)
{        
    UIView *myCommonView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 150.0, 50.0)];
    myCommonView.backgroundColor = [UIColor colorWithPatternImage:iPhoneSpecificImage];
    // bunch of other conditional code
} 
else
{
    UIView *myCommonView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 250.0, 150.0)];
    myCommonView.backgroundColor = [UIColor colorWithPatternImage:iPadSpecificImage];
    // bunch of other conditional code
}
  • 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-20T10:42:40+00:00Added an answer on May 20, 2026 at 10:42 am

    A much better alternative to using loads of if/else statements is to have multiple app delegates. An easy way to do this is to create an AppDelegate_iPhone & AppDelegate_iPad and respectively bind them (in IB) to the different XIBs that get loaded on launch. Now you have a way to programmatically add different items to each delegate.

    This also can lead to an issue where you want to share UI elements between the delegates. In this case, you can create shared views that are used by both delegates (just import the view controller in both cases).

    The code should structurally look something like this.

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

Sidebar

Related Questions

I have a universal app. On the iPad, when pressing an annotation pin it
I do most development testing on my iPad. When I test an iPhone app,
I was doing a project as Universal binary for iPhone/iPad. I created the iPhone
I have a Universal app which is targeting 10.5 and which uses garbage collection.
I have a universal iOS app with a custom view that has three buttons,
My language is PHP, but the algorithm should be fairly universal. I have an
Have you guys had any experiences (positive or negative) by placing your source code/solution
Forgive me coder for I have sinned. I put some code into a dll
I've followed all posts that I've found about creating a Universal App that uses
Have just started using Google Chrome , and noticed in parts of our site,

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.