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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:29:57+00:00 2026-06-14T11:29:57+00:00

I am changing some code from XIBs to storyboard. There seems to be a

  • 0

I am changing some code from XIBs to storyboard. There seems to be a substantial difference in the timing of setting frame bounds of the subviews of a storyboard scene.

A technique this code frequently uses is this:

  • a UIView subview has dimensions defined in the XIB or storyboard file (allowing somebody other than the programmer to modify the UI)
  • The UIViewController has a link to the object as an IBObject UIView *
  • in the UIViewController’s - viewWillAppear(), certain calculations are made and drawing is done based upon those calculations.

For example, in our XIB or Storyboard file, there’s a UIView that we wish to cut up into four regions. The controller looks at the bounds of that UIView, looks at its frame, and then in the UIView draws four boxes, each one quarter the size.

In .h:

IBOutlet UIView *outputColorKeyView;

In .m’s viewWillAppear:

CGRect keyBounds = [outputColorKeyView bounds];

float high = keyBounds.size.height;
float wide = keyBounds.size.width;

float cellWidth = wide/4.0;

XLog(@"Dimensions for the color key are: %f %f", high, wide);

My problem is that under XIBs, this worked fine: I was able to see that the dimensions of the region I had to draw in was 200 points wide (for example), and the cells could be drawn 50 points wide.

Under Storyboards, this is no longer working for me: I get a frame of (0,0,0,0) when I am calling from the controller’s viewWillAppear method:

[18:09:16.901|4096] Dimensions for the color key are: 0.000000 0.000000

However, run from later in the program’s life cycle (triggered by a button), I get the correct result:

[18:09:35.812|4096] Dimensions for the color key are: 36.000000 734.000000

Is there any way to get this information before the view appears? I would think so, but viewWillAppear seems like the last opportunity before views are actually rendered. Or is there some obvious switch that I am missing that will make this technique work as intended?

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-14T11:29:58+00:00Added an answer on June 14, 2026 at 11:29 am

    The answer was given in an answer to my followup question … the place to do this stuff is after the layout is done, in viewDidLayoutSubviews

    It is not clear to me why the information changed, from the data in the initial description file (whether XIB or Storyboard) being available as early as viewDidLoad to now being (0,0,0,0), but it is a difference to be aware of if you follow a lot of the tutorial code out there in books and on the net.

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

Sidebar

Related Questions

I'm changing some Haskell code from using lists to sets. I understand everything required,
After changing and saving some code in my controller, RailsDevTweaks seems to ignore the
I'm struggling with some PHP/MySQL code. I am reading from 1 table, changing some
I have an issue while changing some code from Bitmap.GetPixel to using a direct
In the process of changing some code, I have spilt some functions into multiple
I have some code that I am porting from an SGI system using the
I am trying to get some code working from an example I came across.
When I'm changing some Java source code and my server is running, hot deploy
I am attempting to move some code from one VS2008 project to another. The
I'm changing some legacy code so that is uses smart pointers. Our projects pre-date

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.