2011-05-31 56 views

回答

0

我终于成功地在我的cocos2d-mac Xib中得到了一个N​​SScrollView。

诀窍是,您必须通过首先将假视图设置为scrollView的documentView,然后从其父视图中删除openGLView,然后将openGLView从NSScrollView主视图覆盖(为滚动条留出空间)再次添加它(所以OpenGLView绘制在ScrollView上)。可以按如下方式做到这一点:

appDelegate = [[NSApplication sharedApplication] delegate]; 
// Set up NSScrollView with dummy empty view as big as the layer 
NSRect rect = NSMakeRect(0, 0, myLayer.width, myLayer.height); 
NSView *view = [[NSView alloc] initWithFrame:rect]; 
appDelegate.scrollView.documentView = view; 
[view release]; 

// Push OpenGLView back to front 
[appDelegate.glView removeFromSuperview]; 
[appDelegate.splitLeftView addSubview:appDelegate.glView]; 

然后,你应该使用滚动条事件更新相应的myLayer位置。