Doug Null
Doug Null

Reputation: 8327

how to add Back button to go back to previous MonoTouch storyboard view?

In my Xamarin Studio C# MonoTouch storyboard, I have several views and each one has a button to do a modal seque to common view call "ultrasound".

How do I add a Back button to Ultrasound view that will go back to previous view?

I sequed each view by modal to the Ultrasound view.
I added the Ultrasound Back button wired to method button_ultrasound_back, but nothing happens:

Ultrasound_Controller.m - (IBAction)button_ultrasound_back:(id)sender { [self.navigationController popViewControllerAnimated:YES];
}

When I try moving the popViewControllerAnimated line into Ultrasound_Controller.cs, then the "self" causes an error.

And, if I change the seques from other view to Ultrasound view from modal to push, then Ultrasound view crashes app.

Upvotes: 1

Views: 1714

Answers (1)

Blounty
Blounty

Reputation: 3358

You need to use the push segue as apposed to a modal. Push requires you to have a UINavigationController and you first view set as its initial view controller. Once you have done this back buttons happen for free, no need to code them yourself.

This is a good intro into Storyboards. It is Obj-C but easy to follow.

Upvotes: 3

Related Questions