ios - UIModalTransitionStylePartialCurl 使我的应用程序崩溃

标签 ios objective-c

这是我的 viewController.m 文件

- (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];

}

我有另一个类 SimpleViewController。这个类中有一个像这样的按钮操作。
- (IBAction)dismissMeAction:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

我的默认、翻转和溶解按钮效果很好,但是当我单击 pageCurl 时,我的应用程序崩溃了。这背后的原因是什么?

最佳答案

UIModalTransitionStylePartialCurl是一种需要额外特殊配置的样式。这是来自Apple的文档:

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.



所以你必须确保你的self view 是全屏的,添加全屏演示样式到simpleView如下

- (IBAction)pageCurlAction:(id)sender {

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

}

关于ios - UIModalTransitionStylePartialCurl 使我的应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60797165/

相关文章:

cocoa-touch - UILabel TextAlignement 垂直顶部

iOS - 在将 AQGridView 与 Xib 结合使用时获取 EXC_BAD_ACCESS

ios - Xcode 6.3 : Comparison of address of 'UIApplicationOpenSettingsURLString' not equal to a null pointer is always true 打开设置警告问题

objective-c - iOS - 如何为网络套接字创建读写流?

ios - 如何从 SKScene 呈现 UIAlertController

ios - 如何使用带有自定义对象的 Set 类型作为数据源

ios - 在Titanium中,暂停事件和ios中的registerBackgroundService有什么区别?

ios - 搜索整个 UITableView 单元格的 UISearchBar

iphone - IOS CS193p - 为什么 IBAction 连接被拖到 .m 文件而不是 .h?

iphone - iOS : SA_OAuthTwitterController callback after authorization