繁体   English   中英

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

[英]My App crash on iPad before even application:didFinishLaunchingWithOptions:

在ipad上运行时,我的应用程序崩溃了以下崩溃日志。 它在iphone设备上运行良好。 您可能会注意到,它在尝试设置窗口时崩溃。 我到处搜索,但在任何其他主题中都没有看到这样的问题。

谢谢你的帮助。

*** 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
)

编辑1

问题比我想象的要复杂得多。 这就是我所做的。

  1. 实现的方法在[UIButtonLabel setLineBreakMode:]周围调整,以便我可以看到导致为LineBreakMode使用nil的原因。 我发现如果将lineBreakMode设置为除NSLineBreakByWordWrapping以外的其他东西,它最终会崩溃。
  2. 为了临时使它工作,我将lineBreakMode强制转换为NSLineBreakByWordWrapping ,这在这种情况下并不是什么大问题,因为标签在我的应用程序中永远不会被查看。

编辑2

在使用lineBreakMode修复问题后,我现在遇到了同样的问题,但这次是[UILabel setShadow:]。 请注意,它在标签上崩溃,我没有更改任何阴影属性(颜色,偏移或blurRadius)。 我也得到了相同的问题,但这次是使用了paragraphStyle

这意味着我绝对不能继续使用这种方法,因为它似乎在正在发生的事情中被打破。

编辑3

当我将应用程序的部署目标更改为通用时,我没有上述任何问题。

我在一个类别中覆盖了这两个函数并猜测是什么? 即使您在AppDelegate中控制应用程序之前,这些功能似乎也被ios调用。 由于某些原因,在ipad上这个回报为零。 删除类别修复了问题。

+ (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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM