Objective c 多个UIViewController和OpenGLView(Cocos2D)之上的透明UITableView

Objective c 多个UIViewController和OpenGLView(Cocos2D)之上的透明UITableView,objective-c,uitableview,uiviewcontroller,cocos2d-iphone,uicolor,Objective C,Uitableview,Uiviewcontroller,Cocos2d Iphone,Uicolor,这是我的密码: // View Controller with navigation bar InAppPurchaseViewController *purchaseViewController = [[InAppPurchaseViewController alloc] init]; purchaseViewController.title = @"Magasin"; purchaseViewController.navigationItem.rightBarButtonItem = [[[

这是我的密码:

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

这是你的答案

@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;

不要在
容器上显示视图控制器

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
希望这有帮助

编辑:

根据我在app delegate中的内容,我认为您可以尝试如下实例化RootViewController:

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

您让tableview对象将其设置为clear color Property:1-为
UITableView
UITableViewCell
将BG设置为
[UIColor clearColor]
。2-将
UITableView
UITableViewCell
Opaque
设置为
NO
。您是否尝试过,看看如果不这样做会发生什么:
[container setView:[[CCDirector sharedDirector]openGLView]?只是想弄清楚UITableView和Cocos2D之间是否存在某种故障……是的,如果我没有设置openGLView,模态UIViewController就不会出现。基本上什么也没发生=/第一行中的“viewController”是什么?所以我很快尝试了,但似乎还不够。目前,我的应用程序是基于openGLview的(我使用coco2d场景和图层,并在上面弹出ViewController)。问题是我不想做相反的事。。。使用这个rootViewController方法,当我按下“PurchaseButton”时不会发生任何事情,我不知道为什么。没有错误…请发布您的应用程序代理界面定义和
appdidfishload
的主体,好吗?我使用了这种方法,而且效果很好,所以您的
viewController
成员应该有问题。当你展示另一个视图控制器时,你是否检查过它是否为零?你使用的是哪个版本的Cocos2D?我使用的是V1.0.0,你为什么要问?
    CC_DIRECTOR_INIT
ViewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
ViewController.wantsFullScreenLayout = YES;
[ViewController setView:[[CCDirector sharedDirector] openGLView]];
    ...