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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:09:02+00:00 2026-06-18T06:09:02+00:00

In reading the View Programming Guide from Apple it is apparent they have not

  • 0

In reading the View Programming Guide from Apple it is apparent they have not updated it for constraints. So a couple of questions:

  1. Many posts here talk about NOT using -initWithFrame when initializing a new UIView or setting it to CGRectZero or some equivalent. How would you handle this then?:

    -(id)initWithFrame:(CGRect)frame
    {
        self = [super initWithFrame:frame];
        if (self){
    
        //Set up rounded rectangle ivar
        CGRect frame = [self bounds];
        CGFloat radius = frame.size.height / 2;
        _rectPath = [UIBezierPath bezierPathWithRoundedRect:frame cornerRadius:radius];
        } 
    }
    

    and then putting the drawing code in the drawRect:. I have found that it won’t init properly without a frame. (Obviously, I’m initing this UIView and immediately setting constraints but no frame immediately). This code set’s frame = (0,0,0,0) because constraints haven’t been computed yet.

    If we don’t put this code in init where would we put it? Also, I thought it was good practice to init all our stuff we needed in the view in init.

    So this leads to question…

  2. When is -updateConstraints called in the runtime cycle and when does the view compute it’s bounds using those constraints? I have noticed that the view really doesn’t know what it’s bounds are until after -layoutSubviews. Is there another place before this that the UIView knows it’s bounds if it has only been set with constraints?

Sorry about all the questions, but they all kinda seem connected. Thanks for the looks.

  • 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-18T06:09:03+00:00Added an answer on June 18, 2026 at 6:09 am

    Your problem with your frames is not related to auto layout. View size changes all the time. It is almost never the same as during object instantiation. You need to create/calculate the size of paths to fit the current size during drawRect, not when you first create the view.

    The only objects you should set during init are properties and/or ivars that the rest of your class relies on existing in a certain state.

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

Sidebar

Related Questions

I have a list view populated by an adapter reading from SQLite database. When
I'm trying to make a custom view in Django admin. I'm reading from this
Reading across difference lineage of CPU created by intel , many questions aroused in
I'm reading the manual here: http://zendframework.com/manual/en/zend.view.helpers.html but I'm still confused. I have a script
I've been reading the Beginning iPhone 4 Development book and they have one tutorial
I recently bought Programming Scala , and have been reading through it. The language
I've been reading up on assembly. From what I understand about programming languages, it
I just found web2py a couple days ago, and have been reading the documentation
From aperformance optimization point of view: Reading a file in Java - is a
I'm reading data from a sqlite database however in my detailed view one of

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.