0

I've been trying to make my pushed view controller dismiss or go back one once a confirm action has taken place. I read the many posts in stackoverflow on this subject (I've never done it before) e.g: How to perform Unwind segue programmatically?

but had quite some problems. First of all, the ctrl drag from view controller to exit, didn't work though that seems to be a bug in Xcode 6, so I added the following workaround as advised and changed the class back and forth:

@interface RequestLessonViewController ()

- (IBAction)unwindToMyViewController: (UIStoryboardSegue *)segue;

@end

This allowed me to add in the segue from my action button to Exit. I also of course gave it an identifier (unwindSegue).

I then added the performWithSegueWithIdentifier line in my buttons code as follows:

- (IBAction)requestLessonAction:(UIButton *)sender {

    // PUT CONFIRM POP UP IN HERE ???
    NSLog(@"ADD A LESSON REQUEST TO LESSONS DATABASE");
    UIAlertView *confRequest = [[UIAlertView alloc] initWithTitle:@"Lesson Request Submitted"
                                                         message:@"Congratulations"
                                                        delegate:nil
                                               cancelButtonTitle:@"OK"
                                               otherButtonTitles:nil];
    [confRequest show];


    [self performSegueWithIdentifier:@"unwindSegue" sender:self];



}

However my unwind is still not being kicked off.

Maybe this is still a problem due to xcode 6.4 and I need to use a different work around?

Anyway any help in this would be great

Thanks

Community
  • 1
  • 1
Kitcc
  • 2,138
  • 4
  • 24
  • 42
  • Hi Kitcc, can you explain how are you pushing this view controller you want to unwind or dismissed using segue in storyboard? is it push or present or custome segue? – Muhammad Awais Sep 15 '15 at 04:42
  • Hi @MuhammadAwais its a Push segue from the previous view controller – Kitcc Sep 15 '15 at 05:02
  • This might be of interest if you're still on Xcode 6.4 - check which OS your running on...! http://stackoverflow.com/questions/25654941/unwind-segue-not-working-in-ios-8 – Rich Mar 17 '16 at 12:20

1 Answers1

0

I fixed this using this very useful and clear github from Bradley.

https://github.com/bradley/iOSUnwindSegueProgramatically

Basically I wasn't creating the following type of method on the viewcontroller I was returning too, but inside the one I was trying to exit from :-/ All clear now thanks.

- (IBAction)returnToStepOne:(UIStoryboardSegue *)segue {
    NSLog(@"And now we are back.");
}
Kitcc
  • 2,138
  • 4
  • 24
  • 42