简体   繁体   English

甚至在申请之前我的应用程序在iPad上崩溃:didFinishLaunchingWithOptions:

[英]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. 这就是我所做的。

  1. Implemented method swizzling around [UIButtonLabel setLineBreakMode:] so that I can see what is causing to use nil for the LineBreakMode. 实现的方法在[UIButtonLabel setLineBreakMode:]周围调整,以便我可以看到导致为LineBreakMode使用nil的原因。 I found out that if lineBreakMode is set to something else than NSLineBreakByWordWrapping it ultimately crash. 我发现如果将lineBreakMode设置为除NSLineBreakByWordWrapping以外的其他东西,它最终会崩溃。
  2. To temporary make it work I am forcing the lineBreakMode to NSLineBreakByWordWrapping which is not a big deal in this case because the label is never seens in my app. 为了临时使它工作,我将lineBreakMode强制转换为NSLineBreakByWordWrapping ,这在这种情况下并不是什么大问题,因为标签在我的应用程序中永远不会被查看。

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.

相关问题 application:didFinishLaunchingWithOptions:在应用崩溃时被调用的方法 - application:didFinishLaunchingWithOptions: method getting called on app crash application:didFinishLaunchingWithOptions:在iPad上没有被调用 - application:didFinishLaunchingWithOptions: not getting called on iPad application:didFinishLaunchingWithOptions 在 viewDidLoad 之前加载 - application:didFinishLaunchingWithOptions loading before viewDidLoad iPhone应用程序在didFinishLaunchingWithOptions之前崩溃 - Iphone app crashes before didFinishLaunchingWithOptions 甚至在启动应用程序并消失之前,都会显示ios位置权限。在这种情况下,也不会调用didFinishLaunchingWithOptions - Ios Location Permission is displayed even before App is launched and disappears Also didFinishLaunchingWithOptions is not called in this Scenario didFinishLaunchingWithOptions未调用,但应用程序正在运行并面临崩溃 - didFinishLaunchingWithOptions not called but app is running and faced with crash ipad 1崩溃-我的应用在某处不好 - ipad 1 Crash - my app is bad somewhere iOS在didFinishLaunchingWithOptions之前崩溃:索引0超出了空数组的范围 - iOS crash before didFinishLaunchingWithOptions: index 0 beyond bounds for empty array iPad上的UIScrollView崩溃应用程序 - UIScrollView crash application on iPad 在iPad中崩溃,但在iPhone中没有 - Crash application in iPad but not in iPhone
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM