gpt4 book ai didi

objective-c - 几个 UIViewController 和 OpenGLView (Cocos2D) 之上的透明 UITableView

转载 作者:搜寻专家 更新时间:2023-10-30 19:44:19 24 4
gpt4 key购买 nike

这是我的代码:

// 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];

UITableView 在 purchaseViewController 中。

我正在考虑使用 [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];
}

最佳答案

而不是在 container 上呈现 View Controller :

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

应该工作的是将它呈现在 cocos2D 模板为您创建的 Root View Controller 上。它通常可以通过应用程序委托(delegate)访问:

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

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

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

@synthesize viewController; //-- .m file

希望这对您有所帮助。

编辑:

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

    CC_DIRECTOR_INIT
ViewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
ViewController.wantsFullScreenLayout = YES;
[ViewController setView:[[CCDirector sharedDirector] openGLView]];
...

关于objective-c - 几个 UIViewController 和 OpenGLView (Cocos2D) 之上的透明 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12317659/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com