zoukankan      html  css  js  c++  java
  • Ipad弹出UIAlertControllerStyleActionSheet时发生崩溃

    pad弹出UIAlertControllerStyleActionSheet时,在iphone上运行正常,但在ipad上崩溃,解决代码如下:

    UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:@"请选择图片" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];

        if (isiPad) {//判断是否为ipad

            UIPopoverPresentationController *popover = alertVc.popoverPresentationController;

            if (popover) {

                popover.sourceView = view;//视图中的某个view

                popover.sourceRect = view.bounds;

                popover.permittedArrowDirections = UIPopoverArrowDirectionDown;//alertVC弹出的位置

            }

        }

        

        UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

            

        }];

        

        UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"相册" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

        

        }];

        UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {

            [alertVc dismissViewControllerAnimated:YES completion:nil];

        }];

        

        [alertVc addAction:action1];

        [alertVc addAction:action2];

        [alertVc addAction:action3];

        

        [self presentViewController:alertVc animated:YES completion:nil];

  • 相关阅读:
    [SDOI2015] 序列统计
    [BZOJ3514] Codechef MARCH14 GERALD07加强版
    [CF1082E] Increasing Frequency
    [CF1093G] Multidimensional Queries
    [HNOI2013] 切糕
    [HEOI2017] 寿司餐厅 + 最大权闭合子图的总结
    [BZOJ3771] Triple
    [HEOI2016] 字符串
    [总结] 后缀数组学习笔记
    [Luogu 3613] 睡觉困难综合征
  • 原文地址:https://www.cnblogs.com/lmg4819/p/7595783.html
Copyright © 2011-2022 走看看