4

这是我的代码:

// View Controller with navigation bar
InAppPurchaseViewController *purchaseViewController = [[InAppPurchaseViewController alloc] init];
purchaseViewController.title = @"Magasin";
purchaseViewController.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissViewController:)] autorelease];
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:purchaseViewController] autorelease];

// Add `purchaseViewcontroller` TO container AND container ON openGLView
UIViewController *container = [[UIViewController alloc] init];
[container setView:[[CCDirector sharedDirector] openGLView]];
[container setModalTransitionStyle: UIModalTransitionStyleCoverVertical];
[container presentViewController:navController animated:YES completion:nil];

UITableViewpurchaseViewController 中。

我正在考虑使用[UIColor clearColor],但无论我使用它,我的UITableView. 单元格变得不可选择和不可滑动(除了单元格中的元素)

编辑:appdelegate

这是.h

@class AudioEngine;
@class RootViewController;
@class Score;

@interface AppDelegate : NSObject <UIApplicationDelegate, GameCenterManagerDelegate>

@property int CurrentPackage;
@property int CurrentScore;
@property int CurrentHighScore;
@property BOOL SoundShouldPlay;
@property BOOL PauseScreenUp;
@property(nonatomic, retain) AudioEngine *CustomAudioEngine;
@property(nonatomic, retain) GameCenterManager *CustomGameCenterManager;
@property(nonatomic, retain) UIWindow *window;
@property(nonatomic, readonly) RootViewController *ViewController;
@property(nonatomic, retain) NSString* CurrentLeaderBoard;
@property(nonatomic, retain) NSMutableArray *TenLastScoresArray;

+(AppDelegate *)get;
-(void)connectToGameCenter;
-(void)addScoreToLastScore:(Score*)score;

该方法确实完成了启动

-(void)applicationDidFinishLaunching:(UIApplication*)application
{
    CC_DIRECTOR_INIT();
    self.CurrentLeaderBoard = kLeaderboardID;
    [[SKPaymentQueue defaultQueue] addTransactionObserver:[InAppPurchaseSingleton sharedHelper]];
    [AudioEngine preloadBackgroundMusic];
    [AudioEngine playBackgroundMusic:3];
    self.SoundShouldPlay = YES;
    [SceneManager goSplash];
}
4

1 回答 1

3

而不是在以下位置显示视图控制器container

UIViewController *container = [[UIViewController alloc] init];
...
[container presentViewController:navController animated:YES completion:nil];

应该在 cocos2D 模板为您创建的根视图控制器上显示它。它通常可以通过应用委托访问:

UIViewController *rootViewController = (UIViewController*)[(YOURAPPDELEGATE*)[[UIApplication sharedApplication] delegate] viewController];
[rootViewController presentViewController:navController animated:YES completion:nil];

viewController是 cocos2D 默认模板添加到应用程序委托类的 ivar。它通常是私有的,因此您需要定义一个访问器:

@property (nonatomic, readonly) RootViewController *viewController; //-- .h file

@synthesize viewController; //-- .m file

希望这可以帮助。

编辑:

根据我的应用程序委托中的内容,我认为您可以尝试像这样实例化 RootViewController:

    CC_DIRECTOR_INIT
ViewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
ViewController.wantsFullScreenLayout = YES;
[ViewController setView:[[CCDirector sharedDirector] openGLView]];
    ...
于 2012-09-16T10:31:22.100 回答