natesymer/FHSTwitterEngine

Presenting view on successfull login without showing initial view

rakii opened this issue · 1 comments

On user successfull login with twitter and authorization i want to present another view without coming back to the same login with twitter button.
help me where to present the view

hmm it really depends how you setup your app, here's an example with the demo project

  1. change the app delegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
    self.viewController = [[ViewController alloc]init];

    UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:self.viewController];
    _window.rootViewController = navi;
    [_window makeKeyAndVisible];
    return YES;
}
  1. change the view controller
- (void)loadView {
    [super loadView];
    self.view.backgroundColor = [UIColor lightGrayColor];

    self.theTableView = [[UITableView alloc]initWithFrame:UIScreen.mainScreen.bounds style:UITableViewStylePlain];
    _theTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    _theTableView.dataSource = self;
    _theTableView.delegate = self;
    _theTableView.contentInset = UIEdgeInsetsMake(20+44, 0, 0, 0);
    _theTableView.scrollIndicatorInsets = _theTableView.contentInset;
    [self.view addSubview:_theTableView];

    /*
    UINavigationBar *bar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, (UIDevice.currentDevice.systemVersion.floatValue >= 7.0f)?64:44)];
    bar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
    UINavigationItem *navItem = [[UINavigationItem alloc]initWithTitle:@"FHSTwitterEngine"];
    navItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"XAuth" style:UIBarButtonItemStylePlain target:self action:@selector(loginXAuth)];
    navItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"OAuth" style:UIBarButtonItemStylePlain target:self action:@selector(loginOAuth)];
    [bar pushNavigationItem:navItem animated:NO];
    [self.view addSubview:bar];
    */

    UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"OAuth" style:UIBarButtonItemStylePlain target:self action:@selector(loginOAuth)];
    self.navigationItem.rightBarButtonItem = rightButton;

    [[FHSTwitterEngine sharedEngine]permanentlySetConsumerKey:@"Xg3ACDprWAH8loEPjMzRg" andSecret:@"9LwYDxw1iTc6D9ebHdrYCZrJP4lJhQv5uf4ueiPHvJ0"];
    [[FHSTwitterEngine sharedEngine]setDelegate:self];
    [[FHSTwitterEngine sharedEngine]loadAccessToken];
}
- (void)loginOAuth {
    UIViewController *loginController = [[FHSTwitterEngine sharedEngine]loginControllerWithCompletionHandler:^(BOOL success) {
        NSLog(success?@"L0L success":@"O noes!!! Loggen faylur!!!");
        [_theTableView reloadData];

        UIViewController *controller = [[UIViewController alloc] init];
        controller.title = @"New";
        controller.view.backgroundColor = [UIColor redColor];

        [self.navigationController pushViewController:controller animated:YES];
    }];
    [self presentViewController:loginController animated:YES completion:nil];
}