【发布时间】:2012-07-03 20:19:35
【问题描述】:
我正在将使用此tutorial 的 iPhone 应用程序移植到 Mac 应用程序中。我已经能够让文本显示在 NSScrollView 中,但我无法让文本滚动,我希望有人知道我错过了什么。
在 iPhone 应用中,CTView 是 UIScrollView 的子类
CTView.h:
@interface CTView : UIScrollView <UIScrollViewDelegate> {
1) 但是 AppKit 中没有 NSScrollViewDelegate。 NSScrollView 缺少委托接口是问题吗?
因此对于 Mac 应用,CTView.h 如下所示:
@interface CTView : NSScrollView
在 CTView.m 我有
[self setHasHorizontalScroller:YES];
[self setAcceptsTouchEvents:YES];
还在 CTView.m 中,我创建了一个 NSMutableArray 的帧
self.frames = [NSMutableArray array];
并用框架填充数组。我还为我希望能够滚动浏览的完整大图像设置了文档视图的框架:
[[self contentView] setFrame:[self bounds]];
[self.documentView setFrame: NSMakeRect(0, 0, totalPages * self.bounds.size.width, textFrame.size.height)];
第一帧在 CTView 中可见,但是当我移动水平滚动条时,第二帧不显示在 CTView 中。
我正在使用 Xcode 4.3.3 和 Mac OS X 10.7.4。
有谁知道我需要做什么与 UIScrollView 不同才能使 NSScrollView 能够滚动帧?
【问题讨论】:
标签: objective-c cocoa osx-lion appkit nsscrollview