我使用Facebook的iOS SDK安裝教程根視圖控制器:https://developers.facebook.com/docs/mobile/ios/build/應用程序窗口預計將有在應用程序啓動年底
後第4步:添加註銷您的應用程序,
我得到一個空白屏幕上的5.1模擬器(xcode的4.3.2)和控制檯顯示一個消息:
應用窗口被預期具有在應用程序啓動的端部的根視圖控制器
EDIT-1
感謝您的答覆; 我在創建應用程序時選擇了「單一視圖應用程序」模板。在MainStoryBoard.storyboard中,我創建了一個對象併爲其分配了MyGreatIOSAppAppDelegate類。將此對象的viewController出口拖放到View Controller。
這裏是MyGreatIOSAppAppDelegate.m代碼
#import "MyGreatIOSAppAppDelegate.h"
#import "xxxViewController.h"
@implementation IJSAppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
@synthesize facebook;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
// Add the logout button
UIButton *logoutButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
logoutButton.frame = CGRectMake(40, 40, 200, 40);
[logoutButton setTitle:@"Log Out" forState:UIControlStateNormal];
[logoutButton addTarget:self action:@selector(logoutButtonClicked)
forControlEvents:UIControlEventTouchUpInside];
[self.viewController.view addSubview:logoutButton];
facebook = [[Facebook alloc] initWithAppId:@"id" andDelegate:self];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"]
&& [defaults objectForKey:@"FBExpirationDateKey"]) {
facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
if (![facebook isSessionValid]) {
[facebook authorize:nil];
}
return YES;
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [facebook handleOpenURL:url];
}
- (void)fbDidLogin {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
}
// Method that gets called when the logout button is pressed
- (void) logoutButtonClicked:(id)sender {
[facebook logout];
}
- (void) fbDidLogout {
// Remove saved authorization information if it exists
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"]) {
[defaults removeObjectForKey:@"FBAccessTokenKey"];
[defaults removeObjectForKey:@"FBExpirationDateKey"];
[defaults synchronize];
}
}
@end
難道您發佈'MyGreatIOSAppAppDelegate.m'。你可以編輯這個帖子來做到這一點。 – Drew 2012-03-23 18:36:55
你解決了這個問題嗎?如果你發佈瞭解決方案,我會遇到同樣的問題。 – Hosni 2012-06-04 12:42:35
您使用的是哪個版本的Xcode?不同的版本有不同的項目模板。你可以發佈'main.c'和你的應用程序委託標題嗎?還有你的故事板和Info.plist中的對象列表? – Jim 2012-07-28 23:15:36