objective-c - 在 xcode4 中设置 GData ios 客户端后,无法使用 OAuth

标签 objective-c ios gdata

我关注 this blog将 GData 设置到我的 ios 项目,构建成功,一切正常,但是当我将 GTMOAuth2ViewControllerTouch View 添加到我的窗口时,它只是显示一个没有任何内容的黑色 View 。在我的项目中构建 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;

@end

GDAppDelegate.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;
}

最佳答案

我通过将 GData 和 OAuth 库类直接添加到我的应用中解决了这个问题

关于objective-c - 在 xcode4 中设置 GData ios 客户端后,无法使用 OAuth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9037168/

相关文章:

IOS 将 boost 类声明为类变量

iphone - 如何在 iOS 4.0+ 中以字节为单位获取 UIImage 的大小?

ios - 如何使用 NSPersistentCloudKitContainer 启动并运行默认项目?

iOS 自动更新订阅 veirfyReceipt 返回与设备不同的 base64 收据

ios - 刷新前检查GDataServiceGoogleCalendar是否有更新?

iphone - 自动标签切换

iphone - 使用 AVAudioRecorder 重新录制

ios - 如何在表格 View 单元格中的 View 内设置 View 的角半径?

youtube - 包含空格的用户的YouTube GDATA播放列表供稿

api - Haskell REST/GDATA API 库