こんにちは、私はiOS用のアプリを作成するのが初めてなので、質問が少しばかげている場合は申し訳ありません。Facebookにログインして友達リストを取得することが一部にすぎないアプリを作成しようとしているので、Facebookから開発者に提供する例を使用したいのですが、次のようないくつかのメソッドを持つappDelegateファイルがあります。
#import "FPAppDelegate.h" #import "FPViewController.h" @implementation FPAppDelegate @synthesize window = _window; @synthesize rootViewController = _rootViewController; - (BOOL)application:(UIApplication *)application ....... return [FBSession.activeSession handleOpenURL:url]; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [FBFriendPickerViewController class]; ........ return YES; } - (void)applicationWillTerminate:(UIApplication *)application { [FBSession.activeSession close]; }
そして、hファイルとmファイルを含むFPViewControllerのxibファイルがあるので、この例をアプリで使用するためのより良い方法は、2つのappDelegateファイルを使用できないことを理解し、UIResponderであるFPAppDelegateをUIViewControllerクラスに変更しようとしていますこのように私のアプリのどこかからそれをプッシュするには:
- (IBAction)loginFacebook:(id)sender
{
NSLog(@"Facebook");
delegateViewController *appDelegate = [[delegateViewController alloc] initWithNibName:nil bundle:NULL];
[self.navigationController pushViewController: appDelegate animated:YES];
}
ここで、delegateViewControllerは、次のように変更した例のFPAppDelegateです。
#import "delegateViewController.h"
#import "AppDelegate.h"
#import "FPViewController.h"
@interface delegateViewController ()
@end
@implementation delegateViewController
@synthesize window2=_window2;
@synthesize rootViewController2=_rootViewController2;
- (BOOL)application:(UIApplication *)application
......
return [FBSession.activeSession handleOpenURL:url];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FBFriendPickerViewController class];
......
self.window2 = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window2.rootViewController = navigationController;
[self.window2 makeKeyAndVisible];
return YES;
}
- (void)applicationWillTerminate:(UIApplication *)application {
........
[FBSession.activeSession close];
}
しかし、それは機能していないので、xibファイルも変更する必要がある場合はどうなりますか?または、プロジェクトのappDelegateファイルを変更しますか?または、私のアプリでこの例を使用する別の方法がありますか?これを説明してほしい。