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的实例对象。
  • 相关阅读:
    星战代码小电影
    CDlinux 安装
    网络正常使用,图标状态显示不正常
    查询正在执行的SQL语句DBCCINPUTBUFFER
    如何在MYSQL下所有指定数据库名下执行SQL
    GHOST完成后出现GRUB解决方法
    MySql Cast与Convert函数
    MYSQL查询数据库表索引的硬盘空间占用
    警惕企业中的五种虚假执行力
    开启笔记本win7的虚拟热点笔记本变成wifi
  • 原文地址:https://www.cnblogs.com/CH520/p/15691367.html
Copyright © 2011-2022 走看看