我最近在XCode 9上更新了我们的ObjC应用程序。一切都很好(我甚至更新到iPhone X的新布局),其中一个viewControllers(内置于IB)只有一个问题。这个viewController显示了一个包含新闻的tableView,可以从两个来源访问:
当我尝试从第二种情况打开viewController时,应用程序崩溃并显示下一条消息:
2017-10-17 12:53:26.747396-0500 verifica [17299:1270771] *断言失败 - [_ UIButtonBarButtonVisualProviderIOS _addConstraintsForBackgroundImageWithOffset:isBackButton:],/ BuildRoot / Library / Cache / com.apple.xbs /来源/ UIKit_Sim / UIKit的-3694.4.18 / _UIButtonBarButtonVisualProviderIOS.m:485 2017-10-17 12:53:26.855489-0500 verifica [17299:1270771] * 由于未捕获的异常终止应用程序' NSInternalInconsistencyException',原因:' _UIButtonBarButtonVisualProviderIOS不能没有背景任何内容' ***第一次抛出调用堆栈: ( 0 CoreFoundation 0x000000010ba151cb exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010af48f41 objc_exception_throw + 48 2 CoreFoundation 0x000000010ba1a362 + [NSException raise:format:arguments:] + 98 3基金会0x0000000106a22089 - [NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193 4 UIKit 0x000000010860cd92 - [_ UIButtonBarButtonVisualProviderIOS _addConstraintsForBackgroundImageWithOffset:isBackButton:] + 1079 5 UIKit 0x000000010860c903 - [_ UIButtonBarButtonVisualProviderIOS _configureBackgroundForButton:fromBarButtonItem:isBackButton:] + 1060 6 UIKit 0x0000000108610610 - [_ UIButtonBarButtonVisualProviderIOS configureButton:fromBarButtonItem:] + 2630 7 UIKit 0x000000010860dcaf - [_ UIButtonBarButtonVisualProviderIOS configureButton:withAppearanceDelegate:fromBarItem:] + 148 8 UIKit 0x0000000107ff3096 - [_ UIButtonBarButton _configureFromBarItem:appearanceDelegate:isBackButton:] + 86 9 UIKit 0x0000000107ff2c20 - [_ UIButtonBarButton configureFromBarItem:withAppearanceDelegate:] + 53 10 UIKit 0x00000001085a2049 - [_ UIButtonBar _updatedViewForBarButtonItem:withView:] + 338 11 UIKit 0x00000001085a0add __32 - [_ UIButtonBar _newGroupLayout:] _ block_invoke + 82 12 UIKit 0x00000001085960d3 - [_ UIButtonBarItemLayout _updateItemView] + 53 13 UIKit 0x000000010859667c - [_ UIButtonBarItemLayout _configure] + 40 14 UIKit 0x000000010859518f - [_ UIButtonBarLayout configure] + 60 15 UIKit 0x00000001085952d9 - [_ UIButtonBarLayout addLayoutViews:] + 49 16 UIKit 0x000000010859864e - [_ UIButtonBarItemGroupLayout _iterateConfiguredLayouts:] + 228 17 UIKit 0x000000010859872f - [_ UIButtonBarItemGroupLayout _addLayoutViews:] + 116 18 UIKit 0x000000010859523d - [_ UIButtonBarLayout addLayoutViews:layoutGuides:constraintsToActivate:constraintsToDeactivate:] + 111 19 UIKit 0x00000001085a1264 - [_ UIButtonBar _layoutBar] + 1833 20 UIKit 0x00000001085a3b44 - [_ UIButtonBarStackView updateConstraints] + 48 21 UIKit 0x000000010870d8b6 - [UIView(AdditionalLayoutSupport)_sendUpdateConstraintsIfNecessaryForSecondPass:] + 161 22 UIKit 0x000000010870ded2 - [UIView(AdditionalLayoutSupport)_updateConstraintsIfNeededCollectingViews:forSecondPass:] + 1296 23 UIKit 0x000000010870dd51 - [UIView(AdditionalLayoutSupport)_updateConstraintsIfNeededCollectingViews:forSecondPass:] + 911 24基金会0x00000001069acde1 - [NSISEngine withBehaviors:performModifications:] + 131 25 UIKit 0x000000010870e703 __100- [UIView(AdditionalLayoutSupport)_updateConstraintsIfNeededWithViewForVariableChangeNotifications:] _ block_invoke + 90 26 UIKit 0x000000010870cf61 - [UIView(AdditionalLayoutSupport)_withUnsatisfiableConstraintsLoggingSuspendedIfEngineDelegateExists:] + 104 27 UIKit 0x000000010870e272 - [UIView(AdditionalLayoutSupport)_updateConstraintsIfNeededWithViewForVariableChangeNotifications:] + 160 28 UIKit 0x000000010870f38c - [UIView(AdditionalLayoutSupport)_updateConstraintsAtEngineLevelIfNeededWithViewForVariableChangeNotifications:] + 401 29 UIKit 0x0000000107c671b6 - [UIView(Hierarchy)layoutBelowIfNeeded] + 1517 30 UIKit 0x00000001084a74cd - [_ UINavigationBarTransitionContextPush _prepareContentView] + 130 31 UIKit 0x00000001084a8b2b - [_ UINavigationBarTransitionContextPush准备] + 133 32 UIKit 0x000000010878d15a - [_ UINavigationBarVisualProviderModernIOS _performAnimationWithTransitionCompletion:transition:] + 740 33 UIKit 0x0000000107cb60b6 - [UINavigationBar _pushNavigationItem:transitionAssistant:] + 359 34 UIKit 0x0000000107cb58e2 - [UINavigationBar _pushNavigationItemUsingCurrentTransition:] + 368 35 UIKit 0x0000000107cb5a47 - [UINavigationBar pushNavigationItem:animated:] + 179 36 UIKit 0x0000000107cb02cf - [UINavigationBar _performUpdatesIgnoringLock:] + 47 37 UIKit 0x0000000107cb5b51 - [UINavigationBar _pushNavigationItem:transition:] + 152 38 UIKit 0x0000000107d97f37 __71- [UINavigationController pushViewController:transition:forceImmediate:] _ block_invoke + 371 39 UIKit 0x0000000107d9812c __71- [UINavigationController pushViewController:transition:forceImmediate:] _ block_invoke.1981 + 114 40 UIKit 0x0000000107d92bcf __98- [UINavigationController _shouldSkipHostedRefreshControlUpdateSchedulingDeferredUpdateIfNecessary] _block_invoke + 18 41 UIKit 0x0000000107d94b25 - [UINavigationController _startDeferredTransitionIfNeeded:] + 1343 42 UIKit 0x0000000107d95b90 - [UINavigationController __viewWillLayoutSubviews] + 115 43 UIKit 0x0000000107fec2ae - [UILayoutContainerView layoutSubviews] + 231 44 UIKit 0x0000000128bc4a9f - [UILayoutContainerViewAccessibility layoutSubviews] + 42 45 UIKit 0x0000000107c7c551 - [UIView(CALayerDelegate)layoutSublayersOfLayer:] + 1331 46 QuartzCore 0x000000010773a4ba - [CALayer layoutSublayers] + 153 47 QuartzCore 0x000000010773e5a9 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 401 48 QuartzCore 0x00000001076c71cd _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 365 49 QuartzCore 0x00000001076f2ae4 _ZN2CA11Transaction6commitEv + 500 50 UIKit 0x0000000107bd8687 _afterCACommitHandler + 272 51 CoreFoundation 0x000000010b9b7db7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23 52 CoreFoundation 0x000000010b9b7d0e __CFRunLoopDoObservers + 430 53 CoreFoundation 0x000000010b99c324 __CFRunLoopRun + 1572 54 CoreFoundation 0x000000010b99ba89 CFRunLoopRunSpecific + 409 55 GraphicsServices 0x000000010f3fd9c6 GSEventRunModal + 62 56 UIKit 0x0000000107badd30 UIApplicationMain + 159 57 verifica 0x0000000103ce9f0f main + 111 58 libdyld.dylib 0x000000010ac32d81 start + 1 ) libc ++ abi.dylib:以NSException类型的未捕获异常终止
该应用程序在XCode 9之前运行良好。我已经在模拟器(iOS,10.3,10.3.1和11)和iOS 11的iPhone上运行它,并且在案例2中一直崩溃。
我已经搜索了控制台中提及的几个术语,但唯一相似的是http://www.cocoachina.com/bbs/read.php?tid-1726269.html,我使用了谷歌翻译,一个人说:"主要是由于navigantionBarItem图片和偏移引起的文本位置"。
正如我所说,视图是使用普通的导航控制器在IB中构建的,按钮中没有偏移。与其他类似的viewControllers工作正常的唯一区别是在案例1中显示的右侧navBarButton,但在viewDidLoad中显示下一个代码的案例2中没有:
if (self.fromAppDelegate) {
self.doneButton.title = @"Cerrar";
self.doneButton.enabled = YES;
} else self.doneButton.enabled = NO;
我确信这将是一个简单的解决方案,但现在我无法找到它。我希望有人可以帮助我。
答案 0 :(得分:1)
好的,当我在IB中检查按钮的配置时,我注意到它的宽度(Size Inspector)为零。我将其更改为80,因此按钮现在显示在预览中。我还在Attributes Inspector中将它从Custom系统项更改为Done,并在代码中添加了else语句的下一行:
self.doneButton.title = @"";
它有效,应用程序不再崩溃,但是按钮,如果没有启用,可以看作是一直完成这不是我想要的(上面的代码没有工作,因为它是设置为系统按钮,duh)。所以,我将其更改回自定义并删除默认标题aaaand ...一切都像以前一样(检查问题中的图像),但应用程序仍然有效。什么?好吧,并非一切都像以前一样:上面的代码是唯一的变化。如果我评论该行,应用程序再次崩溃。
我不知道这是一个错误还是一个新要求,但我希望它对某人有用(我知道答案会很简单)。