zoukankan      html  css  js  c++  java
  • UIAlertController和UIActivityViewController在ipad中的兼容性问题

    1、报错提示

    • 1.1 UIAlertController

      • Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController (<UIAlertController: 0x1048f5600>) of style UIAlertControllerStyleActionSheet from
    • 1.2 UIActivityViewController

      • Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIActivityViewController (<UIActivityViewController: 0x103840000>). In its current trait environment, the modalPresentationStyle of a UIActivityViewController with this style is UIModalPresentationPopover.

    2、解决办法

    • 问题原因:这两个crash原因都是因为在ipad上进行UIAlertController和UIActivityViewController的使用的时候,都需要瞄点。
    • 2.1 UIAlertController

    // 兼容ipad
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
      alert.popoverPresentationController.sourceView = sourceView;
      alert.popoverPresentationController.sourceRect = sourceView.bounds;
      alert.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
    }
    
    • 2.1 UIActivityViewController

    // 兼容ipad
    if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        vc.popoverPresentationController.sourceView = self.view;
        vc.popoverPresentationController.sourceRect = CGRectMake(self.view.frame.size.width/2.0, self.view.frame.size.height/2.0, 1.0, 1.0);
        vc.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionAny;
    }
    
    • 提示:其中vc就是对应的UIAlertController、UIActivityViewController的实例对象。
  • 相关阅读:
    Bootstrap(6)图标菜单按钮组件
    Bootstrap(6)辅组类和响应式工具
    Bootstrap(5)栅格系统
    Bootstrap(4) 表单和图片
    Bootstrap(3) 表格与按钮
    Bootstrap(2) 排版样式
    Bootstrap(1) 概述与环境搭建
    requirejs简单应用
    Validate常用校验
    VSS2005源代码管理启用http方式
  • 原文地址:https://www.cnblogs.com/CH520/p/15691367.html
Copyright © 2011-2022 走看看