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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:34:15+00:00 2026-06-10T11:34:15+00:00

I have a view in a xib which contains UIImageView. I’m setting the image

  • 0

I have a view in a xib which contains UIImageView. I’m setting the image to be displayed in the xib and it loads and displays correctly.

However in some circumstances I want the loaded image to be replaced with another image at runtime, so I am doing this:

NSArray* viewObjects  = [[NSBundle mainBundle] loadNibNamed:@"ParentView"owner:self options:nil];
id object = [viewObjects objectAtIndex:0];
parentView *parentView = (ParentView*)[viewObjects objectAtIndex:0];

UIImage *image = [UIImage imageNamed: @"iconName"];
UIImageView *iv = [[UIImageView alloc] initWithImage: image];
iv.frame = parentView.icon.frame;
parentView.icon = iv;

parentView.icon is a UIImageView. The image variable is not nil, nor is iv as the code executes.

iconName is a .png called “iconName@2x.png” which is in my project and if I set it as the UIImageView within the .xib then it is loaded and displayed correctly. But if I set another icon in the .xib and attempt to replace it at runtime with the code above then its not getting replaced.

I can’t figure out why this isn’t working.

  • 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-10T11:34:17+00:00Added an answer on June 10, 2026 at 11:34 am

    You are creating a new image view but don’t add it to the view hierarchy. Either use the existing image view and assign a new UIImage to it or add the newly created view to view hierarchy using addSubview.

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

Sidebar

Related Questions

i have view controller which contains a button which show the image library ,if
I have a xib with a view which contains two views which each contain
I have 3 file: MyViewController.h MyViewController.m MyViewController.xib MyViewController.xib have some view which i removed?
I created view-based application. I have got a sampleGameViewContrioller.xib, which contains main View, and
I have a table view which loads another xib file and uses the content
In my xib file I have some View. And I have PainView class (UIView).
I have a scroll view, which contains about 40-50 objects of different types. The
I have a UIScrollView which contains a view controller which contains a couple of
I have a UITabBarController in my MainWindow.xib. Each tab contains a UINavigationController which has
I have some view controller, that uses my own view class and XIB interface,

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.