0

I am trying to present a view controller on top of a view using the following code

HubViewController* vc = [HubViewController socialHubViewController];
    CATransition* transition = [CATransition animation];
    transition.duration = 3.0;
    transition.type = kCATransitionPush;
    transition.subtype = kCATransitionFromBottom;
    vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    [vc.view.layer addAnimation:transition forKey:kCATransition];
    [self presentViewController:vc animated:NO completion:^{
        NSLog(@"vc: presented");
    }];

Does not seem to work. Any help appreciated.

stefanosn
  • 3,264
  • 10
  • 53
  • 79
  • That is not how to do a custom animation on presentation. And you surely know by now that "does not seem to work" is not a meaningful problem statement. You have explained neither what you expect / desire nor what actually happens. – matt Feb 26 '22 at 17:15
  • oops i found this code in a stackoverflow post - https://stackoverflow.com/questions/41440934/swift-unable-to-present-view-controller-from-top-to-bottom – stefanosn Feb 26 '22 at 17:16
  • Well it's totally wrong. Who lives by the copy and paste dies by the copy and paste. – matt Feb 26 '22 at 17:17
  • But they are saying on the post that is working...i thought i was doing something wrong...that is why i asked. – stefanosn Feb 26 '22 at 17:18
  • You need use `UIPresentationController` for that – Cy-4AH Feb 26 '22 at 19:09

1 Answers1

0

Issues based on navigation check your code.

or use that another way

HubViewController* vc = [HubViewController socialHubViewController];
    CATransition* transition = [CATransition animation];
    transition.duration = 3.0;
    transition.type = kCATransitionPush;
    transition.subtype = kCATransitionFromBottom;
    vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    [vc.view.layer addAnimation:transition forKey:kCATransition];
    [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:vc animated:NO completion:^{
        NSLog(@"vc: presented");
    }];


    //UIViewController *topVc = [UIApplication sharedApplication].keyWindow.rootViewController;
Akila M
  • 42
  • 7