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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:50:35+00:00 2026-06-03T04:50:35+00:00

I am writing a universal application. As a result I have set it up

  • 0

I am writing a universal application. As a result I have set it up so that my XIB/NIBs are not created with the view controllers, but are created separately and then linked to the view controller by setting the Class Name on the XIB to that of the appropriate view controller (and linking the view on File’s Owner to the view on the XIB). I then load the appropriate XIB/NIB (iPhone or iPad) when the view controller is initialized, like so:

SomeViewController *vc = [[SomeViewController alloc] initWithNibName:@"SomeView-iPhone" bundle:nil];
[self.navigationController pushViewController:vc animated:YES];
[vc release];

Additionally, the iphone version is setup with a UITabBarController at the bottom and a UINavigationController at the top. That is created like this:

MyAppDelegate *appDelegate = (MyAppDelegate *)[UIApplication sharedApplication].delegate;
UINavigationController *localNavigationController;
UITabBarController *tabBarController = [[UITabBarController alloc] init];
NSMutableArray *localControllersArray = [[NSMutableArray alloc] init]; 

//setup the first tab
FirstViewController *vc = [[FirstViewController alloc] initWithNibName:@"FirstView-iPhone" bundle:nil];
localNavigationController = [[UINavigationController alloc] initWithRootViewController:vc];
[localControllersArray addObject:localNavigationController];
[localNavigationController release];
[vc release];

//setup the second tab
SecondViewController *vc = [[SecondViewController alloc] initWithNibName:@"SecondView-iPhone" bundle:nil];
localNavigationController = [[UINavigationController alloc] initWithRootViewController:vc];
[localControllersArray addObject:localNavigationController];
[localNavigationController release];
[vc release];

....

//set the controllers onto the tab bar
tabBarController.viewControllers = localControllersArray;
[localControllersArray release];    

[appDelegate.window setRootViewController:tabBarController];
[tabBarController release];  

All that works perfectly fine. The iPhone views are displayed fine (with working tab bar and nav bar) and navigation works fine. Here’s where things get weird (two dragons weird).

-Most UI elements (labels, buttons, etc) that are positioned in IB show up fine
-If I create a UIScrollView in code and add it to the view, it shows up fine
-If I create a UIScrollView in IB and put it on the view, it gets transposed up by 93 pixels at run time from where it appears in IB at design time
-If I create a UIScrollView in IB as a separate view and then add it to the main view in code it gets transposed up by 93 pixels.

In other words, if I do this:

[scrollView setFrame:CGRectMake(0,0,320,100)];
[self.view addSubview:scrollView]; 

Then it would show up at 0,0 for a UIScrollView that was created in code, but it would show up at (0,-93) for a UIScrollView created in IB (and linked to the ivar via an IBOutlet). Now it just so happens that 93 = 44 + 49, which is the height of the tab bar and nav bar combined. That is clearly not a coincidence.

So the question is, why is iOS moving a scroll view created in IB up by the height of the nav bar and tab bar at runtime (but not other UI elements like UILabel or UIButton)?

EDIT: I have used the code that sets up the tab bar and nav bar before in an iPhone only app, and it didn’t have this issue, so I suspect that this has something to do with using initWithNibName to initialize my view controllers or the manual linking of the XIB files to the VC, as that is what is different in my universal app.

  • 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-03T04:50:37+00:00Added an answer on June 3, 2026 at 4:50 am

    I solved it. I stumbled across this question/answer which did the trick:

    UIView size/position not working on iPad as on iPhone

    This was happening because by default the scroll view created in IB was set to autosizing to the lower left corner. I switched it to bind to the top left corner, and now all is well. Strange.

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

Sidebar

Related Questions

I am writing my first universal app, I have converted my nibs so that
Writing my first C# application...never touched the language before and not much of a
Writing a client application that sends images to a server via a webservice. As
Are there any limitation in writing universal application for iPhone and iPad ? (or
I've been writing my Universal application in portrait mode, and now after about 15
I have a C++ application whose in-memory data set consists of a set of
I'm writing a universal iOS app that a text entry component to it. When
I have created Map application for iPhone and I developed same Map application on
I am writing a universal app that will be used primarily at night. I
Writing a test app to emulate PIO lines, I have a very simple Python/Tk

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.