내 앱으로 Facebook Connect SDK에 로그인 한 후 내 메인보기에 연결하는 데 문제가 있습니다. 사용자가 로그인 한 후에는 본질적으로 내 응용 프로그램 (카메라)의 기본보기를로드하려고하지만 지금까지 어떻게해야 하는지를 알 수 없습니다. 지금은 로그인 만하면 검은 색 빈 화면으로 이동하고 내보기에 도달 할 수 없습니다. Facebook 기능을 추가하기 전에 주 메뉴보기에 아무런 문제가 없습니다.Facebook Connect로 로그인 한 후 내 IOS 앱의 기본보기로 이동하려면 어떻게해야합니까?
다음은 내 appDelegate.h 및 appDelegate.m 코드입니다. viewController 코드와 클래스를 추가하면 도움이 될 것입니다. 내 xib 파일은 "ViewController"입니다.
appDelegate.h
#import "FBConnect.h"
#import <UIKit/UIKit.h>
@class ViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate, FBSessionDelegate>
{
Facebook *facebook;
}
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;
@property (nonatomic, retain) Facebook *facebook;
@end
appDelegate.m
#import "AppDelegate.h"
#import "ViewController.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
@synthesize facebook;
- (void)dealloc
{
[_window release];
[_viewController release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
//if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
// self.ViewController = [[[ViewController alloc] initWithNibName:@"nil" bundle:nil] autorelease];
//}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
facebook = [[Facebook alloc] initWithAppId:@"326350974080015" 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]) {
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"user_photos",
nil];
[facebook authorize:permissions];
[permissions release];
}
return YES;
}
- (void)fbDidLogin {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
self.ViewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [facebook handleOpenURL:url];
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [facebook handleOpenURL:url];
}
@end
나는 시도하고 내 응용 프로그램을 실행할 때 나는이 오류가 무엇입니까 : 나는 실제로 코드를 가지고
2012-03-01 21:04:51.103 friendSpotted[619:f803] Applications are expected to have a root view controller at the end of application launch
을 이게 내 앱에있어 .Delegate.m
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
도움을 주셔서 감사합니다! 나는 실제로 거기에 그 코드를 가지고 있지만 주석 처리했다. 그리고 네, 그것은 ViewController.m 파일에 app delegate에 비해 더 깔끔한 것입니다. 나는 단어에 대한 튜토리얼 단어를 따라갔습니다. :) – Cuchullainn