美文网首页
在ipad上开发遇到的坑

在ipad上开发遇到的坑

作者: 你就在世界的中心 | 来源:发表于2017-03-17 11:13 被阅读0次

UIAlertController

UIAlertController *alertSheet = [UIAlertController alertControllerWithTitle:@"请您选择上传的图片" message:nil preferredStyle:UIAlertControllerStyleActionSheet];

[alertSheet addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    [self cameraButtonClickedPersonVC];
}]];
[alertSheet addAction:[UIAlertAction actionWithTitle:@"相册" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    [self pickImageFromAlbumPersonVC];
}]];
[alertSheet addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {   
}]];


//iPad不加下面两句,使用UIAlertAction 会crash
alertSheet.popoverPresentationController.sourceView = self.view;
alertSheet.popoverPresentationController.sourceRect = CGRectMake(0, 0, 1.0, 1.0);

[self presentViewController:alertSheet animated:YES completion:nil];
Snip20170317_2.png

效果就如上图所示,具体位置根据项目需求来设置。

相关文章

网友评论

      本文标题:在ipad上开发遇到的坑

      本文链接:https://www.haomeiwen.com/subject/xqhenttx.html