I am trying to add facebook to my ios xcode game. I can add a facebook login button on a single view application like this:
FBLoginView *loginview = [[FBLoginView alloc] init];
loginview.frame = CGRectOffset(loginview.frame, 5, 5);
loginview.delegate = self;
[self.view addSubview:loginview];
[loginview sizeToFit];
But when i try and add this to my cocos2d project I get an error on this line:
[self.view addSubview:loginview];
I have tried adding it as a child but that doesn't work either. How can I add the button to the screen?
Since Cocos2D
scenes are not subclassed
from UIViews
, you can't directly add a UIView
as a subview
.
Try the solution in this post: How to create a new UIView programmatically in cocos2d?
The key portion is(iOS<7):
[[[CCDirector sharedDirector] openGLView] addSubview:myview];
For iOS 7, use:
[[[CCDirector sharedDirector] view]addSubview:myview];