2012-09-20 30 views

回答

1

它應該只是返回一個UIView。該「的Cocos2D與UIKit的意見」模板工程採用alternateView方法來創建正是這種集裝箱觀點:

@implementation AppDelegate 

-(id) alternateView 
{ 
    // we want to be a dummy view the self.view to which we add the glView plus all other UIKit views 
    KKAppDelegate* appDelegate = (KKAppDelegate*)[UIApplication sharedApplication].delegate; 

    // add a dummy UIView to the view controller, which in turn will have the glView and later other UIKit views added to it 
    CGRect bounds = [appDelegate.window bounds]; 
    UIView* dummyView = [[UIView alloc] initWithFrame:bounds]; 
    [dummyView addSubview:[CCDirector sharedDirector].view]; 

    return dummyView; 
} 

@end 

此代碼放在你的項目的AppDelegate.m

+0

感謝斯特芬。作爲Kobold2D的新手,有時候「明顯」並不明顯。現在我可以看到真正有用的結構。 –

+1

再次嗨。我試過把這段代碼放到alternateView中,並在其中放置一個斷點,但它看起來像函數永遠不會被調用。是否有需要設置以確保alternateView被調用的開關/配置? –

+0

嗨保羅,你有沒有找到解決方案? – user810395

相關問題