Arnab Ahamed Siam
Arnab Ahamed Siam

Reputation: 513

UIModalTransitionStylePartialCurl Crashes my app

This is my viewController.m file

- (IBAction)defaultAction:(id)sender {
    SimpleViewController *simpleView = [[SimpleViewController alloc]init];
    [self presentViewController:simpleView animated:YES completion:nil];
}

- (IBAction)flipAction:(id)sender {
    SimpleViewController *simpleView = [[SimpleViewController alloc]init];
    [simpleView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [self presentViewController:simpleView animated:YES completion:nil];

}

- (IBAction)dissolveAction:(id)sender {
    SimpleViewController *simpleView = [[SimpleViewController alloc]init];
    [simpleView setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
    [self presentViewController:simpleView animated:YES completion:nil];
}



- (IBAction)pageCurlAction:(id)sender {

    SimpleViewController *simpleView = [[SimpleViewController alloc]init];
    [simpleView setModalTransitionStyle:UIModalTransitionStylePartialCurl];
    [self presentViewController:simpleView animated:YES completion:nil];

}

I have another class SimpleViewController.There is a button action like this in this class.

- (IBAction)dismissMeAction:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

My default, flip and dissolve button works well but when i click pageCurl my apps crashes. What is the reason behind this?

Upvotes: 1

Views: 158

Answers (1)

Asperi
Asperi

Reputation: 258247

The UIModalTransitionStylePartialCurl is a style that requires additional special configuration. Here is from Apple's doc:

Declaration

UIModalTransitionStylePartialCurl Discussion

When the view controller is presented, one corner of the current view curls up to reveal the presented view underneath. On dismissal, the curled up page unfurls itself back on top of the presented view. A view controller presented using this transition is itself prevented from presenting any additional view controllers. This transition style is supported only if the parent view controller is presenting a full-screen view and you use the UIModalPresentationFullScreen modal presentation style. Attempting to use a different form factor for the parent view or a different presentation style triggers an exception.

so you have to make sure your self view is a full-screen and add full-screen presentation style to simpleView as below

- (IBAction)pageCurlAction:(id)sender {

    SimpleViewController *simpleView = [[SimpleViewController alloc]init];
    [simpleView setModalPresentationStyle:UIModalPresentationFullScreen];
    [simpleView setModalTransitionStyle:UIModalTransitionStylePartialCurl];
    [self presentViewController:simpleView animated:YES completion:nil];

}

Upvotes: 1

Related Questions