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? Thanks in advance.

Regards, Deepa

4

1 回答 1

2

尝试将 IKImageBrowserView 放置在 NSScrollView 中,您走在正确的轨道上。但是,不要使用 addSubview(继承自 NSView),而是使用 setDocumentView…</p>

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

Scroll View Programming Guide中有一些很好的信息……</p >

NSScrollView 实例为其文档视图提供滚动服务。这是应用程序必须提供滚动视图的唯一视图。文档视图负责创建和管理滚动视图滚动的内容。

于 2011-04-16T22:47:36.830 回答