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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:30:14+00:00 2026-06-16T03:30:14+00:00

I have a custom UIView class called MyView that I use together with a

  • 0

I have a custom UIView class called MyView that I use together with a UIViewController configured through the storyboard. The majority of the view properties is configured through the Interface Builder; however, I need to adjust a couple of images programmatically before setting them as backgrounds for my button, like this:

-(void)setupVisuals {
    UIImage *image = [[UIImage imageNamed:@"myButton.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
    // _myButton is an IBOutlet property set through the storyboard:
    [_myButton setBackgroundImage:image forState:UIControlStateNormal];
}

The problem is that I cannot call [self setupVisuals] from the initializer*, because _myButton is nil at that time.

I solved the problem by adding this line to MyViewController‘s viewDidLoad:

[(MyView*)self.view setupVisuals];

With this call in place, everything works fine. However, this feels like a work-around, rather than a solution to what is likely a relatively common problem.

Is there a UIView method to override, or any other mechanism to complete the initialization of MyView‘s visuals without tapping into the viewDidLoad: mechanism?


* In this case, the initializer is initWithCoder: because the view is loaded from the storyboard. I verified that the initializer gets called correctly, but the visuals are not ready yet.

  • 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-16T03:30:15+00:00Added an answer on June 16, 2026 at 3:30 am

    It sounds like you are using viewDidLoad: correctly. According to Apple’s docs:

    You usually override this method to perform additional initialization
    on views that were loaded from nib files.

    If your goal is to encapsulate this functionality at the UIView level, try layoutSubviews.

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

Sidebar

Related Questions

I have a custom UIView class. Inside that view, there is an image view.
I have a class that subclasses UIView called DrawView. This class contains custom drawing
I have an custom UIVIewController that is the base class for other controllers and
I have a UIViewController Class which holds 2 custom UIView classes which are: ItemView
i have a custom UIView class,and i have linked my view in IB with
So I have class called CSImageViews (subclass of uiview), that is essentially a row
i have created a custom view class which is a subclass of UIview class
I have a custom UIViewController and custom UIView. I'd like to override the viewcontroller.view
I have a custom UIView class that I want to spin, shrink and move
I have a custom UIView that contains an interactive drawing that is drawn in

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.