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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:23:07+00:00 2026-06-12T14:23:07+00:00

In my application (code listed below), I use a popover to display a series

  • 0

In my application (code listed below), I use a popover to display a series of colors that the user can choose. These colors are used for the color of the drawing they are completing above. I am trying to modify the popover to work the same way, except for this time I would want to display images (the images are saved in the application’s documents folder as png files) instead of blocks of color. Listed below is the working code for the color selector popover. ColorGrid is a UIview which contains an NSArray Colors, as well as two NSUIntegers columnCount and rowCount. I have tried to replace the items in the colors array with UIImages of the png files, as well as UIImageViews but I have not been able to get a successful result (or a compilable one). Listed below is the working code. Could anyone show me how I can change the UIColor items to the images to show them in the grid?

- (IBAction)popoverStrokeColor:(id)sender {
StrokeColorController *scc = [[[StrokeColorController alloc] initWithNibName:@"SelectColorController" bundle:nil] autorelease];
scc.selectedColor = self.strokeColor;
[self doPopoverSelectColorController:scc sender:sender];
}

- (void)doPopoverSelectColorController:(SelectColorController*)scc sender:(id)sender {
  [self setupNewPopoverControllerForViewController:scc];
  scc.container = self.currentPopover;
self.currentPopover.popoverContentSize = scc.view.frame.size;


 scc.colorGrid.columnCount = 2;
 scc.colorGrid.rowCount = 3;




scc.colorGrid.colors = [NSArray arrayWithObjects:
                     //put the following below back in after testing
                      [UIColor blackColor],
                      [UIColor blueColor],
                      [UIColor redColor],
                      [UIColor greenColor],
                      [UIColor yellowColor],
                      [UIColor orangeColor],





                      //[UIColor purpleColor],
                     // [UIColor brownColor],
                     // [UIColor whiteColor],
                     // [UIColor lightGrayColor],
                      //[UIColor cyanColor],
                      //[UIColor magentaColor],


                      nil];
 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(colorSelectionDone:) name:ColorSelectionDone object:scc];

[self.currentPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; //displays the popover and anchors it to the button
}

Thanks for your help. I am new to objective-c.

edit – heres the function with my attempt to insert the images instead of the colors

- (void)doPopoverSelectColorController:(SelectColorController*)scc sender:(id)sender {
[self setupNewPopoverControllerForViewController:scc];
scc.container = self.currentPopover;
self.currentPopover.popoverContentSize = scc.view.frame.size;

// these have to be set after the view is already loaded (which happened
// a couple of lines ago, thanks to scc.view...
scc.colorGrid.columnCount = 2;
scc.colorGrid.rowCount = 3;

//here we need to get the UIImage items to try to put in the array.
NSArray *pathforsave = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [pathforsave objectAtIndex:0];
//here we need to add the file extension onto the file name before we add the name to the path
//[fileName appendString:@".hmat"];
NSString *strFile = [documentDirectory stringByAppendingPathComponent:@"test.png"];
NSString *strFile1 = [documentDirectory stringByAppendingPathComponent:@"test1.png"];
NSString *strFile2 = [documentDirectory stringByAppendingPathComponent:@"test2.png"];
NSString *strFile3 = [documentDirectory stringByAppendingPathComponent:@"test3.png"];
NSString *strFile4 = [documentDirectory stringByAppendingPathComponent:@"test4.png"];
NSString *strFile5 = [documentDirectory stringByAppendingPathComponent:@"test5.png"];

//now for the Images
UIImage *image = [ UIImage imageWithContentsOfFile: strFile];
UIImage *image1 = [ UIImage imageWithContentsOfFile: strFile1];
UIImage *image2 = [ UIImage imageWithContentsOfFile: strFile2];
UIImage *image3 = [ UIImage imageWithContentsOfFile: strFile3];
UIImage *image4 = [ UIImage imageWithContentsOfFile: strFile4];
UIImage *image5 = [ UIImage imageWithContentsOfFile: strFile5];

UIImageView *imageview = [[[UIImageView alloc] initWithImage:image] autorelease];
[self.view addSubview:imageview];
UIImageView *imageview1 = [[[UIImageView alloc] initWithImage:image1] autorelease];
[self.view addSubview:imageview1];
UIImageView *imageview2 = [[[UIImageView alloc] initWithImage:image2] autorelease];
[self.view addSubview:imageview2];
UIImageView *imageview3 = [[[UIImageView alloc] initWithImage:image3] autorelease];
[self.view addSubview:imageview3];
UIImageView *imageview4 = [[[UIImageView alloc] initWithImage:image4] autorelease];
[self.view addSubview:imageview4];
UIImageView *imageview5 = [[[UIImageView alloc] initWithImage:image5] autorelease];
[self.view addSubview:imageview5];

imageview.image = image;
imageview1.image = image1;
imageview2.image = image2;
imageview3.image = image3;
imageview4.image = image4;
imageview5.image = image5;



scc.colorGrid.colors = [NSArray arrayWithObjects:
// When attempting to add the images like this - get the error identified expected 
// after the e in image, at the end bracket. Putting a * does nothing to change the error
[image],

// When adding one of the Imageviews, i get the same error as above 
//below is how I attempted to add it
[imageView],



// 


                      nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(colorSelectionDone:) name:ColorSelectionDone object:scc];

[self.currentPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; //displays the popover and anchors it to the button
}
  • 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-12T14:23:08+00:00Added an answer on June 12, 2026 at 2:23 pm

    Remove your square brackets around image and/or imageView :

    scc.colorGrid.colors = [NSArray arrayWithObjects:
    // Not : [image] but
     image,
    // or
    imageView,
    // Not : [imageView],
     nil];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below I listed some code from simple Rails application. The test listed below fails
I have an Android Application that has the AndroidManifest.xml listed below. After uploading to
In a C++ application that can use just about any relational database, what would
I'm currently using the validation code listed here in an application. I'd like to
I have this relatively large numerical application code that may run for a few
I'm stumped about a stack overflow error--out of stack space (application error code: 12246)--that
I have an application that is used in image processing, and I find myself
I have method in my N-layered application that returns List<Employee> . Below is the
Assuming that: The C# source code below is compiled under .NET 2.0 (CLR 2.0);
below is the html code for a button in my asp.net application which uses

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.