Custom Unwind Segue for iOS 8 and iOS 9

后端 未结 2 1399
有刺的猬
有刺的猬 2021-02-09 20:31

My question is, how do I get the following custom unwind segue to work on a device with a version prior to iOS 9 as well as on a device running iOS 9?

I

2条回答
  •  情书的邮戳
    2021-02-09 21:13

    I slightly modified your code.
    I don't have to consider whether push or modal.
    It seems to work fine.

    - (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(NSString *)identifier
    {
        UIStoryboardSegue *segue;
        if ([fromViewController isKindOfClass:[MyViewController class]]) {
            segue = [[CustomSegue alloc] initWithIdentifier:identifier source:fromViewController destination:toViewController]; //Custom Unwind Segue
        }
        else {
            if ([super respondsToSelector:@selector(unwindForSegue:towardsViewController:)]) {
                [super unwindForSegue:segue towardsViewController:toViewController];
            }
            segue = [super segueForUnwindingToViewController:toViewController fromViewController:fromViewController identifier:identifier];
        }
    
        return segue;
    }
    

提交回复
热议问题