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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:06:46+00:00 2026-06-10T02:06:46+00:00

Okay, I’m new to programming in XCode and Objective-C, and have a question. I

  • 0

Okay, I’m new to programming in XCode and Objective-C, and have a question.

I can add a UIImageView normally using the drag and drop features in the Storyboard Builder thing. Then I can access it in code by creating a connection to the relavent ViewController, with a control drag and drop and then I can create a outlet. It is then declared in the *.h file with the @property line and synthesized in the *.m file.

BUT, what if I have a more complex view and it would take far too long drop and drag everything onto the screen and what if I wanted to change the position of the objects during execution?

I have tried using this in the ViewDidLoad Method:

NSMutableArray *mutableArray = [NSMutableArray array];
UIImage * pic = [UIImage imageNamed: @"Blue.png"];
for (int x = 0;x<10;x++){
    for (int y =0;y<10;y++){
        UIImageView *imageView = [[UIImageView alloc] initWithImage:pic];
    imageView.frame =CGRectMake(x*23,y*41,32,41);
[mutableArray addObject:imageView];
    }
}

This, I hoped would make a grid of UIImageViews and hold them in a NSMutableArray, but nothing appears on screen. How do you do a similar process to the drag and drop but in code? I realize I’m not synthesizing anything, and I only declare one instance UIImageView, but I thought If I put the declaration in the for loops then it would complain because it would be creating multiple variables with the same name. Is there anyway to create a load of UIImageViews in a few lines of code using a loop? I though of maybe just editing the sting used as the identifier for the pointer variable e.g. “image1”, “image2″….. But I didn’t know how to use a string type variable as the name of an identifier.

P.S. – I googled the CGRectMake procedure and the parameters are (x-coordinates,y-coordinates,width,height).

Any help would be greatly appreciated :).

  • 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-10T02:06:48+00:00Added an answer on June 10, 2026 at 2:06 am

    You need to add them to the subview.

    [self.view addSubview:imageView];
    

    Instead of adding them to an array you could use tags to identify the individual UIImageView, it all depends on what you prefer.

    UIImage * pic = [UIImage imageNamed: @"Blue.png"];
    int tagInt=1;
    for (int x = 0;x<10;x++){
        for (int y =0;y<10;y++){
            UIImageView *imageView = [[UIImageView alloc] initWithImage:pic];
            imageView.frame =CGRectMake(x*23,y*41,32,41);
            imageView.tag=tagInt;
            [self.view addSubview:imageView];
            tagInt++;
        }
    }
    

    Then to access the individual UIImageView

    UIImageView *imageView = (UIImageView*)[self.view viewWithTag:1];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, next PHPExcel question. I have an HTML form that users fill out and
Okay this question is very simple: I have a facebook page, and a website.
Okay so my question is this. Say I have a simple C++ code: #include
Okay say your using a app, and you opened a new activity and then
Okay. So my question is simple: How can I assign the value of a
Okay, so what I have is basically three dynamic drop down boxes and a
Okay so I can't figure this out. Like a file that I using grep
Okay this seems like a real noob question. I currently have a simple html
Okay, I have the following create action #posts_controller, nested resource under discussions def create
Okay, so I have my post.php page. If you are not logged in, you'll

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.