1

I would like to create a Cocoa library Test.dylib that provides Icon view using IKImageBrowserView. I cannot create IKImageBrowserView in nib since dylib does not support Resources. So, I am creating the IKImageBrowserView programmatically as follows:

IKImageBrowserView *browser = [[IKImageBrowserView alloc]initWithFrame:[self bounds]];
Datasource *ds = [[dataSource alloc]init];
[browser setDataSource:ds];
[browser setDelegate:ds];

But, when there are more items than visible area vertical scrollers should be displayed which is not happening.

How do I support scrolling for IKImageBrowserView that is created programmatically?

I have tried the following with no positive results:

NSScrollView *scroller = [[NSScrollView alloc]initWithFrame:[self bounds]];
[scroller addSubview:browser];

How do I solve this?

halfer
  • 19,824
  • 17
  • 99
  • 186
spd
  • 2,114
  • 1
  • 29
  • 54

1 Answers1

2

You're on the right track with trying to place the IKImageBrowserView inside of a NSScrollView. However, instead of using addSubview (inherited from NSView), use setDocumentView…

NSScrollView *scroller = [[NSScrollView alloc]initWithFrame:[self bounds]];
[scroller setDocumentView:browser];
[scroller setHasVerticalScroller:YES];

The Scroll View Programming Guide has some good info in it…

NSScrollView instances provide scrolling services to its document view. This is the only view that an application must provide a scroll view. The document view is responsible for creating and managing the content scrolled by a scroll view.

Ryan Grimm
  • 1,972
  • 1
  • 11
  • 7