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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:45:34+00:00 2026-05-30T01:45:34+00:00

I added 6 UIImageViews in Interface Builder. Those are declared. @property (nonatomic, strong) IBOutlet

  • 0

I added 6 UIImageViews in Interface Builder.
Those are declared.

@property (nonatomic, strong) IBOutlet UIImageView *Image1;

@property (nonatomic, strong) IBOutlet UIImageView *Image2;

@property (nonatomic, strong) IBOutlet UIImageView *Image3;

@property (nonatomic, strong) IBOutlet UIImageView *Image4;

@property (nonatomic, strong) IBOutlet UIImageView *Image5;

@property (nonatomic, strong) IBOutlet UIImageView *Image6;

Those UIImageView’ name has a rule – “Image” + number.

I want to select those ImageViews dinamically.
For example,

for (NSInteger i = 0; i < 6 ; i++) {

    if(... condition ) 
    {
       //new 
       [[NSString stringWithFormat:@"Image%d", i+1] setHidden:YES];  //--(1) 
    }
    else
    {
        [[NSString stringWithFormat:@"Image%d", i+1] setHidden:NO];  //--(2) 
    }

}

But, this code isn’t correct.
Please tell me more good way.

  • 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-05-30T01:45:35+00:00Added an answer on May 30, 2026 at 1:45 am

    jonkroll’s suggestion to put your image views in an array is a good way to do it, and generally the highest performance.

    Another way is to use key-value coding (KVC) to access your properties by name:

    for (int i = 0; i < 6; ++i) {
        NSString *key = [NSString stringWithFormat:@"Image%d", i + 1];
        UIImageView *imageView = (UIImageView *)[self valueForKey:key];
        imageView.hidden = condition;
    }
    

    Using the view tag, as Mark suggests, is a third way to do it. His answer is a little short on details, so I will provide some.

    You can set the tag in your nib:

    Interface Builder with tag field circled

    So you can set the tag of your Image1 image view to 1, and the tag of your Image2 image view to 2, and so on.

    Then you can find an image view by its tag using the viewWithTag: method on your top-level view:

    for (int i = 0; i < 6; ++i) {
        [self.view viewWithTag:i+1].hidden = condition;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have UIImageViews image1 , image2 , image3 etc. I have the filenames for
I've probably setup the UIImageViews incorrectly. I added them in interface builder. I then
I created a UITableViewCell in Interface Builder which I have added a UIImageView and
I have a UIImageView that I've added a PinchGestureRecognizer to. Currently, the image is
I have one view controller in which I have added UIScrollView & UIImageView programatically.
So I just spent like one hour Googling for some answers. I added UIImageView
Hi so this is my situation up to now. I've added a UIImageView to
I'm trying to explore UIImageView so I added an image Logo.jpg to my projet
I started out with the UISplitViewController template in Xcode 4, and added a UIImageView
I am using a UIImageView with two buttons added as a subview in my

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.