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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:42:30+00:00 2026-06-17T21:42:30+00:00

If I create a UIImageView via Storyboard and add it as a @property into

  • 0

If I create a UIImageView via Storyboard and add it as a @property into a ViewController.h, I can access that UIImageView from anywhere in the ViewController.m via [self UIImageView] or self.UIImageView.

But If I create the UIImageView programmatically from viewDidLoad as you see below, I seem to lose the ability to access it from outside viewDidLoad.

UIImageView *prevImgView = [[UIImageView alloc] init];
UIImageView *currImgView = [[UIImageView alloc] init];
UIImageView *nextImgView = [[UIImageView alloc] init];

NSArray *imageViews = [NSArray arrayWithObjects:prevImgView, currImgView, nextImgView, nil];

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
[self.view addSubview: scrollView];

CGRect cRect = scrollView.bounds;
UIImageView *cView;

for (int i=0; i<imageViews.count; i++) {
    cView = [imageViews objectAtIndex:i];
    cView.frame = cRect;
    [scrollView addSubview:cView];
    cRect.origin.x += cRect.size.width;
}

So later on if I want to modify the image that is being displayed in any one of the UIImageView I’ve created from viewDidLoad, I can’t seem to access it. Does anyone know what I’m doing wrong?

  • 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-17T21:42:31+00:00Added an answer on June 17, 2026 at 9:42 pm

    You would need to create your UIImageView in your header file and then it would be available throughout the rest of the view. You will need to add it to the view in viewDidLoad though.

             Header
             UIImageView *image;
    
             Main // ViewDidLoad
             image = [UIImageView alloc] .....
             [self.view addSubView image];
    
    
             Main Function .....
             [image setImage ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to create UIImageView with image from a link like this http://img.abc.com/noPhoto4530.gif ?
I want to create an iOS app that contains a uiimageview and a button
I'm struggling to create a custom UITableViewCell (in IB) that has a UIImageView on
Example: I have an class that inherits from UIImageView. An object creates an instance
I hope to create thumbnail from an UIImage/UIImageView. There are some undocument solution: http://ofcodeandmen.poltras.com/2008/10/30/undocumented-uiimage-resizing/
i have following code to create cell and add image to it UIImageView* MyImage
I have a button that will programmatically create a UIImageView with an image for
I have a CGMutablePathRef property in a subclassed UIImageview. When I create a new
I want to create a method that will accept a UIButton, UIImageView, or any
I create a project as Single View Application with initial ViewController; add subViewController to

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.