QLPreviewController在共享iOS 9上崩溃

时间:2015-10-05 12:52:09

标签: ios iphone swift qlpreviewcontroller airdrop

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

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

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

enter image description here

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

来自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

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题。 我的解决方案是,对SFAirDropActivityViewController执行某些操作。

代码:

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


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

PrivateFrameworks地址:

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