2011-05-31 21 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位置。