vikas patel
vikas patel

Reputation: 61

Alternative of unwind segue in storyBoard for ios5

I am making an application which is compatible with ios5, ios6 & ios7. I am using unwind segue but it is showing error when i set target lowest to ios5. can anybody suggest me an alternative for unwind segue in ios5

Thanks in advance.

Upvotes: 0

Views: 271

Answers (1)

Mischa
Mischa

Reputation: 17269

I solved this problem by creating my own BackSegue class. It's not a real segue and it inherits directly from NSObject but it also has a method perform that I call whenever I want to go back to the first view controller.

Inside that method you can dismiss the current view controller in order to "unwind" the segue:

- perform {

    ...

    [yourFirstViewController dismissViewControllerAnimated:YES completion:nil];

    ...

}

Alternatively, you can also set dismissViewControllerAnimated:NO in the above code and define your own custom animation for your BackSegue using

// perform animation
[UIView animateWithDuration:.4 animations:^{
    // your animations
} completion:^(BOOL finished) {
    // do completion tasks
}];

(I usually first dismiss the second view controller, keeping its view and adding it on top of the first view controller. Then you can move that view however you like.)

Upvotes: 1

Related Questions