Hi Graham, I tried what you have suggested still only images are shown with titles. May be there is something wrong with my other code segments. Please have a look at my code if you can spot anything wrong. I suspect imageBrowser:itemAtIndex: should have different implementation.
My AppController looks like this: /******************************************************/ #import "AppController.h" @implementation AppController - (void)awakeFromNib { data = [[NSMutableArray alloc] init]; //array of IKBBrowserItem objects [browserView setContentResizingMask:NSViewHeightSizable]; [browserView setDelegate:self]; [browserView setDataSource:self]; [self setDataWithPath:@"/Users/ashisht/Desktop/pics"]; [browserView reloadData]; } - (NSUInteger) numberOfItemsInImageBrowser:(IKImageBrowserView *) aBrowser { return [data count]; } - (id) imageBrowser:(IKImageBrowserView *) aBrowser itemAtIndex:(NSUInteger)index { return [data objectAtIndex:index]; } /******************************************************/ Where as my datasource items look like this: /******************************************************/ @implementation IKBBrowserItem @synthesize image; @synthesize mPath; - (id)initWithImage:(NSImage*)anImage imageID:(NSString*)anPath { if (self = [super init]) { image = [anImage copy]; mPath = [anPath copy]; } return self; } - (void)dealloc { [image release]; [mPath release]; [super dealloc]; } #pragma mark - #pragma mark Required Methods IKImageBrowserItem Informal Protocol - (NSString *) imageUID { return mPath; } - (NSString *) imageRepresentationType { return IKImageBrowserPathRepresentationType /*IKImageBrowserNSImageRepresentationType*/; } - (id) imageRepresentation { return mPath; } #pragma mark - #pragma mark Optional Methods IKImageBrowserItem Informal Protocol - (NSString*) imageTitle { return [[mPath lastPathComponent] stringByDeletingPathExtension]; } - (NSString*) imageSubtitle { NSDictionary* attribs = [image imageAttributes]; int w, h; w = [[attribs objectForKey:@"PixelWidth"] intValue]; h = [[attribs objectForKey:@"PixelHeight"] intValue]; return [NSString stringWithFormat:@"%d x %d", w, h]; } /******************************************************/ > > On 24/02/2009, at 9:50 PM, Ashish Tiwari wrote: > >> I am trying to get finder icon view like behavior in my >> application. Using >> IKImageBrowserView I am able to show icons for contents of a >> directory but I >> also need file/directory name below those icons. For this I am >> trying to >> insert NString into NSImage but text is now showing up in >> IKImageBrowserView. > > > IKImageBrowserVIew has a much better way to handle this specific > labelling requirement. > > The objects it stores should implement the informal protocol for - > imageTitle and -imageSubtitle, and the view will draw those strings > below the icons for you. > > Here are the methods I have in a simple custom object I use - I think > I originally got this from one of Apple's samples though I'm afraid I > forgot exactly which one. It simply provides the browser with the path > to each image. > > --Graham > > > > // > ------------------------------------------------------------------------- > // imageRepresentationType: > // > // Set up the image browser to use a path representation. > // > ------------------------------------------------------------------------- > - (NSString*) imageRepresentationType > { > return IKImageBrowserPathRepresentationType; > } > > // > ------------------------------------------------------------------------- > // imageRepresentation: > // > // Give the path representation to the image browser. > // > ------------------------------------------------------------------------- > - (id) imageRepresentation > { > return mPath; > } > > // > ------------------------------------------------------------------------- > // imageUID: > // > // Use the absolute file path as the identifier. > // > ------------------------------------------------------------------------- > - (NSString*) imageUID > { > return mPath; > } > > > - (NSString*) imageTitle > { > return [[mPath lastPathComponent] stringByDeletingPathExtension]; > } > > > - (NSString*) imageSubtitle > { > NSDictionary* attribs = [self imageAttributes]; > > int w, h; > > w = [[attribs objectForKey:@"PixelWidth"] intValue]; > h = [[attribs objectForKey:@"PixelHeight"] intValue]; > > return [NSString stringWithFormat:@"%d x %d", w, h]; > } > > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com