首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在xcode4中安装xcode4 ios客户端后,无法使用OAuth

在xcode4中安装xcode4 ios客户端后,无法使用OAuth
EN

Stack Overflow用户
提问于 2012-01-27 17:03:50
回答 1查看 902关注 0票数 2

我遵循这个博客设置GData到我的ios项目,构建成功,一切都很好,但是当我在窗口中添加一个GTMOAuth2ViewControllerTouch视图时,它只是显示一个没有任何的黑色视图。在我的项目中构建的GTMOAuth2ViewControllerTouch代码是从http://code.google.com/p/gtm-oauth2/复制的。在gtm-oauth2项目中,OAuth是工作的,我不知道为什么相同的代码不能在我的新项目中工作。

我的代码:

GDAppDelegate.h:

代码语言:javascript
复制
@interface GDAppDelegate : UIResponder <UIApplicationDelegate>{
@private
    UIWindow *_window;
    UINavigationController *mNavigationController;
}

@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) GDViewController *viewController;

@end

GDAppDelegate.m:

代码语言:javascript
复制
#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;
}
EN

回答 1

Stack Overflow用户

发布于 2012-09-14 13:24:41

我也有同样的问题,必须将GTMOAuth2ViewControllerTouch.xib文件包含到我的主要解决方案中。否则,使用静态库可以正常工作。

看起来,.xib文件必须复制到应用程序的资源文件夹中,这样它才能加载它们。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9037168

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档