crizztus
crizztus

Reputation: 307

setHidesBackButton does not work

this one is driving me crazy. From my root view controller I'm pushing another view controller to force the user to enter some credentials in order to login. Unless the credentials aren't correct the user shall not be able to switch back to the root view. To accomplish this I'm trying to hide the back button but for some reason this doesn't work. Any suggestions?

- (void)presentLoginWebView
{
  UIViewController *webViewController = [[UIViewController alloc] init];
  webViewController.title = NSLocalizedString(@"IB_LOG_IN_TITLE", nil);

  UIWebView *webView = [[UIWebView alloc] initWithFrame:webViewController.view.frame];
  webViewController.view = webView;

  [self.navigationController pushViewController:webViewController animated:NO];

  [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:IB_GET_OAUTH_TOKEN_URL]]];
  webView.scalesPageToFit = YES;
  webView.delegate = self; //delegate methods below

  if (deviceVersion > 6)
  {
    [self.navigationController.interactivePopGestureRecognizer setEnabled:NO];
  }
  [self.navigationController.navigationItem setHidesBackButton:YES];

  //The following line doesn't work either
  //self.presentedViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[[UIView alloc] init]];
}

Upvotes: 0

Views: 1886

Answers (2)

alper_k
alper_k

Reputation: 512

The following code will work. Try only navigationItem , not navigationController.navigationItem

webViewController.navigationItem.hidesBackButton = YES;

Upvotes: 2

Akhilrajtr
Akhilrajtr

Reputation: 5182

Try hiding back button of webViewController

webViewController.navigationItem.hidesBackButton = YES;

Upvotes: 1

Related Questions