Jesse
Jesse

Reputation: 891

xcode iphone back button

Seems like this would be a simple thing, but I cannot find any good info on it.

I just want to be able to 'force' the back button to show. I have a main view and when I transfer to another view there is no back button. But then if I transfer to a 3rd view, the back button appears. This seems to always be the case. Only the 2nd transferred to view shows a back button. I need it to show up on all views except the main view.

I dont need to override it, just simply force it to show where it is not showing...

Upvotes: 3

Views: 3296

Answers (2)

pedrouan
pedrouan

Reputation: 12910

Patch's solution (dismissModalViewController)had been unfortunately deprecated and replaced by dismissViewControllerAnimated. Here is the current one:

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

Upvotes: 0

Patrick
Patrick

Reputation: 7185

I know this is an old question, but this might help...

...sometimes you need to embed a view inside a Navigation Controller for the back button to show. Simply select your view controller and select Editor -> Embed In -> Navigation Controller.

If the button does not show (usually if you are presenting a modal view rather than push) then you will need to manually make a 'Cancel' button. Create an action for this and in the method put (I call my method switchback):

-(IBAction)switchback:(id)sender {
    [self dismissModalViewControllerAnimated:YES];
}

Upvotes: 1

Related Questions