• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problems with image cell in table view (was: Re: NSImage -isValid not always right?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with image cell in table view (was: Re: NSImage -isValid not always right?)


  • Subject: Re: Problems with image cell in table view (was: Re: NSImage -isValid not always right?)
  • From: "Peesapaty Ramesh" <email@hidden>
  • Date: Sat, 13 Apr 2002 16:24:51 +0530

hi joar,

i am able to show images in tableview.
thanks for your inputs
regards
ramesh

[TABLE NOT SHOWN]

Hello Ramesh,

You don't say where in your code the snippet is from. It doesn't seem to
really fit anywhere unfortunately... :)
I would set the cell type for columns in awakeFromNib - before they are
used, but after they have been loaded from the nib. You should not set
an image for the cell at this point - that is something you do later on
in the table data source methods. Something like this:

- (void) awakeFromNib
{
// Your other stuff

// Set the cell type
{
NSTableColumn *col = [myTableView
tableColumnWithIdentifier:@"ImageColumn"];
NSImageCell *myImageCell = [[NSImageCell alloc] init];
[col setDataCell:[myImageCell autorelease]];
}
}

- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
if ([[aTableColumn identifier] isEqualToString:@"ImageColumn"]) {
// Here you must make sure to return a proper object value
for the
// cell, or else you will get errors
return [NSImage imageNamed:@"image.giff"];
} else {
NSLog(@"This should never happen");
return nil;
}
}

j o a r

On Friday, April 12, 2002, at 06:56 , Peesapaty Ramesh wrote:

> Hi,
> i am trying to display a image in tableView .
> the code is as follows.
>
>
> NSImageCell *myImageCell;
> NSTableColumn *col = [folderList
> tableColumnWithIdentifier:@"folder"];
> NSImage *myImage = [[NSImage alloc]
> initWithContentsOfFile:@"folder.gif"];
>
> if ([myImage isValid]){
> NSLog(@"Image is valid");
> }
> if ([myImage isKindOfClass:[NSImage class]]){
> NSLog(@"YES");
> }
> myImageCell = [[NSImageCell alloc] init];
> [myImageCell setImage:myImage];
> [col setDataCell:myImageCell];
>
> when it is setting value in the tablecolumn it is giving following
> error.
> "NSImageCell's object value must be an NSImage."
> am i missing anything.
>
> thanks in advance.
> Ramesh
> _______________________________________________
> cocoa-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Resizing NSToolbarItems?
  • Next by Date: Re: Newbie question: floating windows/panels
  • Previous by thread: Re: Resizing NSToolbarItems?
  • Next by thread: Drawing with a mask
  • Index(es):
    • Date
    • Thread