認証のためにサーバーにリクエストを行うログインビューコントローラーがあります。成功したら、現在のView ControllerをアプリケーションのホームタブView Controllerにしたいと思います。pushViewController:viewController、presentModalViewController、またはdismissModalViewControllerAnimatedを使用しようとしました。何も機能しません。提供されているスクリーンショットを見て、私のアプリケーション フローを理解してください。
サンプルコードは次のとおりです。
- (IBAction)facebookLoginButtonClick:(id)sender {
// get the app delegate so that we can access the session property
AppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];
// this button's job is to flip-flop the session from open to closed
if (appDelegate.session.isOpen) {
// if a user logs out explicitly, we delete any cached token information, and next
// time they run the applicaiton they will be presented with log in UX again; most
// users will simply close the app or switch away, without logging out; this will
// cause the implicit cached-token login to occur on next launch of the application
[appDelegate.session closeAndClearTokenInformation];
} else {
if (appDelegate.session.state != FBSessionStateCreated) {
// Create a new, logged out session.
appDelegate.session = [[FBSession alloc] init];
}
// if the session isn't open, let's open it now and present the login UX to the user
[appDelegate.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// and here we make sure to update our UX according to the new session state
[self dismissModalViewControllerAnimated:YES];
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle: nil];
MainViewTabBarController *viewController = (MainViewTabBarController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"mainPageTabBarId"];
[[self navigationController] presentModalViewController:viewController animated:YES];
}];
}
}