0

I'm writing an iPhone app and I start with a main view and when I click a button it switches to my second view using this code...

- (IBAction)addNewCourse
{
    AddCourses *addCourseController = [[AddCourses alloc] initWithNibName:@"AddCourses" bundle:nil];
    [self presentModalViewController:addCourseController animated:YES];

}

Now I am having problems switching BACK to the original view. I use this code...

- (IBAction) back
{
    [self.parentViewController dismissViewControllerAnimated:YES completion:nil];
}

but it doesn't seem to work. Any help would be greatly appreciated. Thanks

  • possible duplicate of [Present and dismiss modal view controller](http://stackoverflow.com/questions/1529632/present-and-dismiss-modal-view-controller) – Rashad Apr 02 '14 at 04:34

1 Answers1

2

Try this code:

[self dismissViewControllerAnimated:YES completion:nil];
Deepak Khiwani
  • 734
  • 1
  • 8
  • 33