Eugene Trapeznikov
Eugene Trapeznikov

Reputation: 3240

Navigation Controller without a "Back" button

In my app i got view, where user adds new object, then he clicks on the "save" button and goes to main view. But after that we see "back" button on the main view. Can i do this segue (new object -> main window) without "back" button?

Upvotes: 4

Views: 9573

Answers (4)

Nicole S
Nicole S

Reputation: 53

In case anyone else is having trouble getting this to work,

'self.navigationItem.hidesBackButton = YES;'

didn't work for me when placed in

'- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil'.

I moved it to '- (void)viewDidLoad' and it now works perfectly. I'm using Xcode 4.5.2.

Upvotes: 3

Sanjeev Rao
Sanjeev Rao

Reputation: 2297

If you are navigating from VC1 to VC2. If you want hide back button when you goto VC2.

Just write this in VC2

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.navigationItem.hidesBackButton = YES;
    }
    return self;
}

OR

- (id)init
{
    self = [super init];
    if (self) {
        self.navigationItem.hidesBackButton = YES;
    }
    return self;
}

Upvotes: 14

Krrish
Krrish

Reputation: 2256

- (IBAction)done:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

Then connect it to a button.

Upvotes: 0

user187676
user187676

Reputation:

Set self.navigationItem.hidesBackButton = YES on the pushed view controller.

Upvotes: 1

Related Questions