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的实例对象。
  • 相关阅读:
    算法大佬推荐
    学习的两个docker指令
    ie兼容问题解决记录
    缓存函数,curry与偏函数
    uni-app开发时遇到的注意点
    let,var,const区别
    递归的简单理解
    宏任务和微任务的进一步理解
    简单实现一个观察者模式
    业余时间
  • 原文地址:https://www.cnblogs.com/CH520/p/15691367.html
Copyright © 2011-2022 走看看