0

QLPreviewController用来预览图像和pdf文件。它适用于 iOS7-9。但是,当我点击 iOS9 设备上的共享按钮时,应用程序立即崩溃,但出现以下异常:

Fatal Exception: NSInvalidArgumentException *** -[__NSCFString rangeOfString:options:range:locale:]: nil argument

这不会发生在带有 iOS9 的模拟器上。我可以在 iOS7 和 8 设备上看到 AirDrop 共享菜单,但(null)描述顶部出现奇怪的标题。这是示例屏幕截图的链接,在带有 iOS7 的 iPhone 5 上拍摄:

在此处输入图像描述

你们有没有遇到过这样的问题?

来自 CrashLytics 的完整堆栈跟踪

Thread : Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x00000001860a0f5c __exceptionPreprocess + 124
1  libobjc.A.dylib                0x000000019ac97f80 objc_exception_throw + 56
2  CoreFoundation                 0x00000001860a0ea4 -[NSException initWithCoder:]
3  Foundation                     0x0000000186efe598 -[NSString rangeOfString:options:range:locale:] + 348
4  Sharing                        0x0000000195064118 -[SFAirDropActivityViewController attributedStringWithTitle:content:]
5  Sharing                        0x00000001950633e0 -[SFAirDropActivityViewController viewDidLoad]
6  UIKit                          0x000000018b5f7610 -[UIViewController loadViewIfRequired] + 1124
7  UIKit                          0x000000018b5f7194 -[UIViewController view] + 28
8  UIKit                          0x000000018bf3a244 __79-[_UIActivityGroupListViewController updateVisibleActivityGroupViewControllers]_block_invoke115 + 112
9  CoreFoundation                 0x0000000185f9e6f0 __53-[__NSArrayI enumerateObjectsWithOptions:usingBlock:]_block_invoke + 100
10 CoreFoundation                 0x0000000185f95418 -[__NSArrayI enumerateObjectsWithOptions:usingBlock:] + 148
11 UIKit                          0x000000018bf39e90 -[_UIActivityGroupListViewController updateVisibleActivityGroupViewControllers] + 456
12 UIKit                          0x000000018bf3a754 -[_UIActivityGroupListViewController viewDidLoad] + 720
13 UIKit                          0x000000018b5f7610 -[UIViewController loadViewIfRequired] + 1124
14 UIKit                          0x000000018b5f7194 -[UIViewController view] + 28
15 UIKit                          0x000000018ba4901c -[UIAlertController setContentViewController:] + 284
16 UIKit                          0x000000018b7f0278 -[UIActivityViewController viewDidLoad] + 1280
17 UIKit                          0x000000018b5f7610 -[UIViewController loadViewIfRequired] + 1124
18 UIKit                          0x000000018b5f7194 -[UIViewController view] + 28
19 UIKit                          0x000000018b969bfc -[UIViewController _setPresentationController:] + 108
20 UIKit                          0x000000018b962e58 -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1328
21 UIKit                          0x000000018b964840 -[UIViewController _presentViewController:withAnimationController:completion:] + 4428
22 UIKit                          0x000000018b967278 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 472
23 UIKit                          0x000000018b6ee0a4 -[UIViewController presentViewController:animated:completion:] + 184
24 UIKit                          0x000000018bc48c84 _UIDocumentInteractionControllerPresentPopoverFromItemOrShowActivityViewController + 356
25 UIKit                          0x000000018bc48a70 -[UIDocumentInteractionController presentOptionsMenuFromBarButtonItem:animated:] + 264
26 QuickLook                      0x000000018af9d220 -[QLPreviewController actionButtonTapped:] + 220
27 UIKit                          0x000000018b62e3c8 -[UIApplication sendAction:to:from:forEvent:] + 100
28 UIKit                          0x000000018b7ad3dc -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 168
29 UIKit                          0x000000018b62e3c8 -[UIApplication sendAction:to:from:forEvent:] + 100
30 UIKit                          0x000000018b62e344 -[UIControl sendAction:to:forEvent:] + 80
31 UIKit                          0x000000018b616c6c -[UIControl _sendActionsForEvents:withEvent:] + 416
32 UIKit                          0x000000018b616db8 -[UIControl _sendActionsForEvents:withEvent:] + 748
33 UIKit                          0x000000018b62dc5c -[UIControl touchesEnded:withEvent:] + 572
34 UIKit                          0x000000018b62d88c -[UIWindow _sendTouchesForEvent:] + 804
35 UIKit                          0x000000018b626ac0 -[UIWindow sendEvent:] + 784
36 UIKit                          0x000000018b5f7a10 -[UIApplication sendEvent:] + 248
37 UIKit                          0x000000018b5f5efc _UIApplicationHandleEventQueue + 5348
38 CoreFoundation                 0x00000001860585a4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
39 CoreFoundation                 0x0000000186058038 __CFRunLoopDoSources0 + 540
40 CoreFoundation                 0x0000000186055d38 __CFRunLoopRun + 724
41 CoreFoundation                 0x0000000185f84dc0 CFRunLoopRunSpecific + 384
42 GraphicsServices               0x00000001910d8088 GSEventRunModal + 180
43 UIKit                          0x000000018b65ef44 UIApplicationMain + 204
4

1 回答 1

1

我遇到了同样的问题。我的解决方案是,对 SFAirDropActivityViewController 做点什么。

编码:

@interface SFAirDropActivityViewController : UIViewController
+ (BOOL)isAirDropAvailable;
@end


@implementation SFAirDropActivityViewController
+ (BOOL)isAirDropAvailable{
 return NO;
}
@end

私有框架地址:

https://github.com/nst/iOS-Runtime-Headers/blob/master/PrivateFrameworks/Sharing.framework/SFAirDropActivityViewController.h

于 2015-11-12T01:52:05.897 回答