我遵循这个博客设置GData到我的ios项目,构建成功,一切都很好,但是当我在窗口中添加一个GTMOAuth2ViewControllerTouch视图时,它只是显示一个没有任何的黑色视图。在我的项目中构建的GTMOAuth2ViewControllerTouch代码是从http://code.google.com/p/gtm-oauth2/复制的。在gtm-oauth2项目中,OAuth是工作的,我不知道为什么相同的代码不能在我的新项目中工作。
我的代码:
GDAppDelegate.h:
@interface GDAppDelegate : UIResponder <UIApplicationDelegate>{
@private
UIWindow *_window;
UINavigationController *mNavigationController;
}
@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) GDViewController *viewController;
@endGDAppDelegate.m:
#import "GDAppDelegate.h"
#import "GData.h"
#import "GTMOAuth2SignIn.h"
#import "GTMOAuth2ViewControllerTouch.h"
@implementation GDAppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
UINavigationController *mainNavigationController = [[UINavigationController alloc] initWithRootViewController:nil];
mainNavigationController.view.frame = CGRectMake(0, 20, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height-20);
[mainNavigationController.navigationBar setBarStyle:UIBarStyleDefault];
[mainNavigationController setToolbarHidden:YES];
NSString *keychainItemName = nil;
NSString *scope = @"https://www.googleapis.com/auth/plus.me";
NSString *clientID = @"181779079861.apps.googleusercontent.com";//self.clientIDField.text;
NSString *clientSecret = @"FAIi_4YiI3vAtYi7Xf1nMF7Q";//self.clientSecretField.text;
SEL finishedSel = @selector(viewController:finishedWithAuth:error:);
GTMOAuth2ViewControllerTouch *viewController;
viewController = [GTMOAuth2ViewControllerTouch controllerWithScope:scope
clientID:clientID
clientSecret:clientSecret
keychainItemName:keychainItemName
delegate:self
finishedSelector:finishedSel];
NSDictionary *params = [NSDictionary dictionaryWithObject:@"en"
forKey:@"hl"];
viewController.signIn.additionalAuthorizationParameters = params;
NSString *html = @"<html><body bgcolor=silver><div align=center>Loading sign-in page...</div></body></html>";
viewController.initialHTMLString = html;
self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];
return YES;
}发布于 2012-09-14 13:24:41
我也有同样的问题,必须将GTMOAuth2ViewControllerTouch.xib文件包含到我的主要解决方案中。否则,使用静态库可以正常工作。
看起来,.xib文件必须复制到应用程序的资源文件夹中,这样它才能加载它们。
https://stackoverflow.com/questions/9037168
复制相似问题