Tencent / QMUI_iOS

QMUI iOS——致力于提高项目 UI 开发效率的解决方案
http://qmuiteam.com/ios
Other
7.09k stars 1.38k forks source link

Crash when push QMUISearchController #94

Closed maxhis closed 7 years ago

maxhis commented 7 years ago

运行环境

具体问题描述

最近在尝试把项目引入QMUIKit,参考demo里的QDSearchViewController写了一个VC,然后push到现有的navigationController里就crash了,错误信息如下。

这么描述可能不太明白,只是我实在没做太多特殊的东西,是否因为我漏掉了什么配置项?谢谢!

BTW, QMUIKit看起来很强大,要是文档再详细一些就好了。

问题截图

2017-03-29 19:47:41.331 MoonBay[23330:1525911] QMUI - <_UINavigationInteractiveTransition: 0x7fd6dac733a0>. Called By -[UINavigationController(QMUI) qmui_viewDidLoad]
2017-03-29 19:47:42.904 MoonBay[23330:1525911] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010e7feb0b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010e23a141 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010e719ac2 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 354
    3   CoreFoundation                      0x000000010e71992b +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
    4   QMUIKit                             0x000000010bedae47 -[UISearchBar(QMUI) setQmui_placeholderColor:] + 327
    5   QMUIKit                             0x000000010bedb2df -[UISearchBar(QMUI) qmui_styledAsQMUISearchBar] + 255
    6   QMUIKit                             0x000000010bea1667 -[QMUISearchController initWithContentsViewController:] + 919
    7   MoonBay                             0x000000010a243d92 _TTOFCSo20QMUISearchControllercfT22contentsViewControllerGSQCSo16UIViewController__GSQS__ + 34
    8   MoonBay                             0x000000010a2411f1 _TFCSo20QMUISearchControllerCfT22contentsViewControllerGSQCSo16UIViewController__GSQS__ + 65
    9   MoonBay                             0x000000010a240e14 _TFC7MoonBay26TagSelectionViewController11viewDidLoadfT_T_ + 116
    10  MoonBay                             0x000000010a241272 _TToFC7MoonBay26TagSelectionViewController11viewDidLoadfT_T_ + 34
    11  UIKit                               0x000000010c412cca -[UIViewController loadViewIfRequired] + 1235
    12  UIKit                               0x000000010c419056 -[UIViewController __viewWillAppear:] + 118
    13  UIKit                               0x000000010c443078 -[UINavigationController _startCustomTransition:] + 1305
    14  UIKit                               0x000000010c453617 -[UINavigationController _startDeferredTransitionIfNeeded:] + 687
    15  UIKit                               0x000000010c4547f1 -[UINavigationController __viewWillLayoutSubviews] + 58
    16  UIKit                               0x000000010c6462bc -[UILayoutContainerView layoutSubviews] + 231
    17  UIKit                               0x000000010c33320b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1268
    18  QMUIKit                             0x000000010bee4431 -[UIView(QMUI_Border) qmui_layoutSublayersOfLayer:] + 65
    19  QuartzCore                          0x000000010f3dd904 -[CALayer layoutSublayers] + 146
    20  QuartzCore                          0x000000010f3d1526 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 370
    21  QuartzCore                          0x000000010f3d13a0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    22  QuartzCore                          0x000000010f360e92 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
    23  QuartzCore                          0x000000010f38d130 _ZN2CA11Transaction6commitEv + 468
    24  UIKit                               0x000000010c269307 _UIApplicationFlushRunLoopCATransactionIfTooLate + 167
    25  UIKit                               0x000000010ca69cab __handleEventQueue + 5843
    26  CoreFoundation                      0x000000010e7a4c01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    27  CoreFoundation                      0x000000010e78a0cf __CFRunLoopDoSources0 + 527
    28  CoreFoundation                      0x000000010e7895ff __CFRunLoopRun + 911
    29  CoreFoundation                      0x000000010e789016 CFRunLoopRunSpecific + 406
    30  GraphicsServices                    0x0000000112d0ea24 GSEventRunModal + 62
    31  UIKit                               0x000000010c2700d4 UIApplicationMain + 159
    32  MoonBay                             0x000000010a246ad7 main + 55
    33  libdyld.dylib                       0x000000011068a65d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
MoLice commented 7 years ago

这是尝试将一个 nil 的值作为 NSDictionary 的 value 导致的 crash,请参考 #72 试试。

maxhis commented 7 years ago

swift项目也是复制QMUIConfigurationTemplate.h/m吗?我这边会提示 Duplicate interface definition for class 'QMUIConfigurationTemplate'

MoLice commented 7 years ago

@maxhis 你是使用 CocoaPod 引入 QMUI 吗?

maxhis commented 7 years ago

是的。

On 2017年3月30日 +0800 11:51, MoLice notifications@github.com, wrote:

@maxhis 你是使用 CocoaPod 引入 QMUI 吗? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

MoLice commented 7 years ago

稍等,我看下

maxhis commented 7 years ago

@MoLice Appreciate if you can give any feedbacks.

MoLice commented 7 years ago

@maxhis 刚刚发了 1.3.7,对可能由 nil 导致的 crash 都做了保护,现在应该不会了。

另外关于对 QMUIConfigurationTemplate.m 的使用,理论上不管 OC 还是 Swift 都需要复制一份到项目里使用,但目前在 CocoaPod 下有问题,我们正在处理,近期会公布 CocoaPod 下新的使用方式。

如果你更新了 1.3.7,应该至少不会 crash,可以正常运行。

maxhis commented 7 years ago

Thanks.

On 2017年3月30日 +0800 17:29, MoLice notifications@github.com, wrote:

@maxhis 刚刚发了 1.3.7,对可能由 nil 导致的 crash 都做了保护,现在应该不会了。 另外关于对 QMUIConfigurationTemplate.m 的使用,理论上不管 OC 还是 Swift 都需要复制一份到项目里使用,但目前在 CocoaPod 下有问题,我们正在处理,近期会公布 CocoaPod 下新的使用方式。 如果你更新了 1.3.7,应该至少不会 crash,可以正常运行。 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

MoLice commented 7 years ago

@maxhis 刚刚更新了 1.5.0 版本,对 3 种使用 QMUI iOS 的方式重新整理,其中对配置表 QMUIConfigurationTemplate 的使用也有明确的说明,有空可以查看哈。

maxhis commented 7 years ago

@MoLice 版本更新真快!👍

另外有个建议,能否做一个swift的guide文档,现在用swift的项目越来越多了,THX!

MoLice commented 7 years ago

@maxhis 嗯,后续整理 Swift 的时候会给个文档