Created
April 16, 2024 21:42
-
-
Save kmdarshan/74a40ed1fae5ba6af12fce8538b40e3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .h file declarations | |
| @property (strong, nonatomic) UINavigationController *navigationController; | |
| .m app delegate implementation | |
| - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
| { | |
| self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | |
| self.navigationController = [[UINavigationController alloc] init]; | |
| self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; | |
| [self.navigationController pushViewController:self.viewController animated:YES]; | |
| // Override point for customization after application launch. | |
| self.window.rootViewController = self.navigationController; | |
| [self.window makeKeyAndVisible]; | |
| return YES; | |
| } | |
| // loading a view based on login | |
| /* | |
| * Callback for session changes. | |
| */ | |
| - (void)sessionStateChanged:(FBSession *)session | |
| state:(FBSessionState) state | |
| error:(NSError *)error | |
| { | |
| switch (state) { | |
| case FBSessionStateOpen: | |
| if (!error) { | |
| // We have a valid session | |
| NSLog(@"User session found"); | |
| //UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil]; | |
| testViewController *tv = [[testViewController alloc] init]; | |
| [self.navigationController pushViewController:tv animated:YES]; | |
| self.navigationController.navigationBarHidden = NO; | |
| //navigationController.navigationItem.backBarButtonItem = backButton; | |
| //[self.window setRootViewController:self.navigationController]; | |
| } | |
| break; | |
| case FBSessionStateClosed: | |
| case FBSessionStateClosedLoginFailed: | |
| [FBSession.activeSession closeAndClearTokenInformation]; | |
| break; | |
| default: | |
| break; | |
| } | |
| [[NSNotificationCenter defaultCenter] | |
| postNotificationName:FBSessionStateChangedNotification | |
| object:session]; | |
| if (error) { | |
| UIAlertView *alertView = [[UIAlertView alloc] | |
| initWithTitle:@"Error" | |
| message:error.localizedDescription | |
| delegate:nil | |
| cancelButtonTitle:@"OK" | |
| otherButtonTitles:nil]; | |
| [alertView show]; | |
| } | |
| } | |
| // code to hide the navigation bar in the base view controller | |
| - (void)viewDidLoad | |
| { | |
| [super viewDidLoad]; | |
| // Do any additional setup after loading the view, typically from a nib. | |
| self.title = @"title"; | |
| self.navigationController.navigationBarHidden = YES; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment