[英]My App crash on iPad before even application:didFinishLaunchingWithOptions:
My app is crashing with the following crashlog when ran on ipad. 在ipad上运行时,我的应用程序崩溃了以下崩溃日志。 It just work fine on iphone devices.
它在iphone设备上运行良好。 As you might notice, it crash while trying to setup the window.
您可能会注意到,它在尝试设置窗口时崩溃。 I have searched everywhere but don't see such an issue in any other topic.
我到处搜索,但在任何其他主题中都没有看到这样的问题。
Thanks for you help. 谢谢你的帮助。
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: NSParagraphStyle)'
*** First throw call stack:
(
0 CoreFoundation 0x000000010e38ff35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010e028bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010e296998 -[__NSDictionaryM setObject:forKey:] + 968
3 UIKit 0x000000010ca99d2d -[UILabel _setLineBreakMode:] + 529
4 UIKit 0x000000010cb7a572 -[UIButtonLabel setLineBreakMode:] + 93
5 UIKit 0x000000010cb86e5c -[UIButton _setupTitleViewRequestingLayout:] + 308
6 UIKit 0x000000010cb7ed15 -[UIButton titleLabel] + 51
7 UIKit 0x000000010cd3c6d8 -[UIZoomViewController loadView] + 476
8 UIKit 0x000000010c9f67f9 -[UIViewController loadViewIfRequired] + 75
9 UIKit 0x000000010c9f6c8e -[UIViewController view] + 27
10 UIKit 0x000000010cd3bfa4 -[UIZoomViewController init] + 78
11 UIKit 0x000000010cd39eeb -[UIClassicController _setupWindow] + 544
12 UIKit 0x000000010cd39b7c +[UIClassicController sharedClassicController] + 140
13 UIKit 0x000000010c8e47dd -[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:] + 666
14 UIKit 0x000000010c8e42ae __88-[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:]_block_invoke + 138
15 UIKit 0x000000010c8e4215 -[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:] + 349
16 UIKit 0x000000010c8cf31a -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 486
17 UIKit 0x000000010c8cedb8 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 336
18 FrontBoardServices 0x000000011064f612 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 265
19 FrontBoardServices 0x000000011065e2a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
20 CoreFoundation 0x000000010e2c553c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
21 CoreFoundation 0x000000010e2bb285 __CFRunLoopDoBlocks + 341
22 CoreFoundation 0x000000010e2bb045 __CFRunLoopRun + 2389
23 CoreFoundation 0x000000010e2ba486 CFRunLoopRunSpecific + 470
24 UIKit 0x000000010c8ce669 -[UIApplication _run] + 413
25 UIKit 0x000000010c8d1420 UIApplicationMain + 1282
26 Edyn 0x0000000109704323 main + 115
27 libdyld.dylib 0x000000010ebd2145 start + 1
28 ??? 0x0000000000000001 0x0 + 1
)
Edit 1 编辑1
The problem is more complicated than I thought. 问题比我想象的要复杂得多。 Here is what I have done.
这就是我所做的。
Edit 2 编辑2
After fixing the issue with lineBreakMode , I am now getting the same issue but this time with [UILabel setShadow:]. 在使用lineBreakMode修复问题后,我现在遇到了同样的问题,但这次是[UILabel setShadow:]。 Note that it crash on label where I didn't change anything to the shadow attributes (color, offset or blurRadius).
请注意,它在标签上崩溃,我没有更改任何阴影属性(颜色,偏移或blurRadius)。 I also get the same issue but this time with paragraphStyle
我也得到了相同的问题,但这次是使用了paragraphStyle
Which mean I can't definitely not keep using this approach as it seems to be something broken in what's happening. 这意味着我绝对不能继续使用这种方法,因为它似乎在正在发生的事情中被打破。
Edit 3 编辑3
When I change the deployment target of my app to universal, I don't have any of the above issues. 当我将应用程序的部署目标更改为通用时,我没有上述任何问题。
I was overriding those two functions in a category and guess what? 我在一个类别中覆盖了这两个函数并猜测是什么? those function seems to be called by ios even before you get control of the app in your AppDelegate.
即使您在AppDelegate中控制应用程序之前,这些功能似乎也被ios调用。 And for some reason on ipad this return nil.
由于某些原因,在ipad上这个回报为零。 Removing the category fixed the problem.
删除类别修复了问题。
+ (id)systemFontOfSize:(CGFloat)sz {
return [UIFont fontWithName:@"HelveticaNeue-Regular" size:sz];
}
+ (id)boldSystemFontOfSize:(CGFloat)sz {
return [UIFont fontWithName:@"HelveticaNeue-Bold" size:sz];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.