简体   繁体   English

在 XCode 9 上更新 ObjC 应用程序

[英]Updating ObjC app on XCode 9

I recently updated our ObjC app on XCode 9. Everything was ok (I even updated to iPhone X new layout), there has been just an issue in one of the viewControllers (built in IB).我最近在 XCode 9 上更新了我们的 ObjC 应用程序。一切正常(我什至更新到 iPhone X 新布局),只是其中一个视图控制器(内置于 IB)出现问题。 This viewController, which shows a tableView with news, can be accessed from 2 sources:这个 viewController 显示了一个带有新闻的 tableView,可以从 2 个来源访问:

  1. From appDelegate if a Push Notification informs about new news.来自 appDelegate 如果推送通知通知新消息。 In this case, a right navBarButton is unhidden so the user can dismiss the view在这种情况下,右侧的 navBarButton 未隐藏,因此用户可以关闭视图
  2. From a specific section, where a normal back button is used从使用普通后退按钮的特定部分

When I try to open the viewController from the second case, the app crashes with the next message:当我尝试从第二种情况打开 viewController 时,应用程序崩溃并显示下一条消息:

2017-10-17 12:53:26.747396-0500 verifica[17299:1270771] * Assertion failure in -[_UIButtonBarButtonVisualProviderIOS _addConstraintsForBackgroundImageWithOffset:isBackButton:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3694.4.18/_UIButtonBarButtonVisualProviderIOS.m:485 2017-10-17 12:53:26.855489-0500 verifica[17299:1270771] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '_UIButtonBarButtonVisualProviderIOS cannot have a background without any content' *** First throw call stack: ( 0 CoreFoundation 0x000000010ba151cb exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010af48f41 objc_exception_throw + 48 2 CoreFoundation 0x000000010ba1a362 +[NSException raise:format:arguments:] + 98 3 Foundation 0x0000000106a22089 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193 4 UIKit 0x000000010860cd92 -[_UIButtonBarButtonVisualProviderIOS _addConstraintsForBackgroundImageWithOffset:isBackButton:] + 1 2017-10-17 12:53:26.747396-0500 verifica[17299:1270771] * 断言失败 -[_UIButtonBarButtonVisualProviderIOS _addConstraintsForBackgroundImageWithOffset:isBackButton:], /BuildRoot/Kits.apple/.Caches/Library/LibrarySUI/.Cachex 3694.4.18/_UIButtonBarButtonVisualProviderIOS.m:485 2017-10-17 12:53:26.855489-0500 verifica[17299:1270771] *终止应用程序由于未捕获的异常'NSInternalInconsistency'a ButtonVisual 不能有任何原因:没有 IOS 按钮可视化的背景'按钮视觉不一致性' ***第一掷调用堆栈:(0的CoreFoundation 0x000000010ba151cb exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010af48f41 objc_exception_throw + 48 2的CoreFoundation 0x000000010ba1a362 + [NSException提高:格式:参数:] + 98 3基础0x0000000106a22089 - [NSAssertionHandler handleFailureInMethod:对象: file:lineNumber:description:] + 193 4 UIKit 0x000000010860cd92 -[_UIButtonBarButtonVisualProviderIOS _addConstraintsForBackgroundImageWithOffset:isBackButton:] + 1 079 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 -[_UIButton 079 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 0x0000000018080050505050505050105050505550Button01UIButton05050105555055950555555595559555555559555955595595595595595595595595595595595595595595595595595559608559559559608555960按钮14 UIKit BarLayout 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 Foundation 0x00000001069acde1 -[NSISEngine withBehaviors:performModifications:] + 131 25 UIKit 0x000000010870e703 __100-[UIView(AdditionalLayoutSupport) BarLayout 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 Foundation 0x00000001069acde1 -[NSISEngine withBehaviors:performModifications:] + 131 25 UIKit 0x00087UI000000000000000007 _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 prepare] + 133 32 UIKit 0x000000010878d15a -[_UINavigationBarVisualProviderModernIOS _performAnimationWithTransitionCompletion:transition:] + 740 33 UIKit 0x0000000107cb60b6 -[UINavigationBar _pushNavigationItem:transitionAssistant:] + 359 34 UIKit 0x000 _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的(层次)layoutBelowIfNeeded] + 1517 30的UIKit 0x00000001084a74cd - [_ UINavigationBarTransitionContextPush _prepareContentView] + 130 31的UIKit 0x00000001084a8b2b - [_ UINavigationBarTransitionContextPush制备] + 133 32的UIKit 0x000000010878d15a - [_ UINavigationBarVisualProviderModernIOS _performAnimationWithTransitionCompletion:过渡:] + 740 33的UIKit 0x0000000107cb60b6 - [UINavigationBar的_pushNavigationItem:transitionAssistant:] + 359 34 UIKit 0x000 0000107cb58e2 -[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 0x00000 0000107cb58e2 - [UINavigationBar的_pushNavigationItemUsingCurrentTransition:] + 368 35的UIKit 0x0000000107cb5a47 - [UINavigationBar的pushNavigationItem:动画:] + 179 36的UIKit 0x0000000107cb02cf - [UINavigationBar的_performUpdatesIgnoringLock:] + 47 37的UIKit 0x0000000107cb5b51 - [UINavigationBar的_pushNavigationItem:过渡:] + 152 38的UIKit 0x0000000107d97f37 __71 - [UINavigationController的pushViewController:过渡:forceImmediate:] _ block_invoke + 371 39的UIKit 0x0000000107d9812c __71- [UINavigationController的pushViewController:过渡: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 -[UILayoutContainerView4 UIKit00x04 00128bc4a9f -[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 0x00000001 00128bc4a9f - [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主+ 111 58 libdyld .dylib 0x00000001 0ac32d81 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException 0ac32d81 start + 1 ) libc++abi.dylib: 以 NSException 类型的未捕获异常终止

The app worked fine before XCode 9. I've run it in the simulator (with iOS, 10.3, 10.3.1 & 11) and on an iPhone with iOS 11, and crashes all the time for case 2.该应用程序在 XCode 9 之前运行良好。我在模拟器(使用 iOS、10.3、10.3.1 和 11)和使用 iOS 11 的 iPhone 上运行它,并且在案例 2 中一直崩溃。

I've searched several of the terms referred in the console, but the only similar was http://www.cocoachina.com/bbs/read.php?tid-1726269.html , I used Google Translate and one guy says: "mainly due to the navigantionBarItem picture and the location of the text caused by the offset".我搜索了控制台中提到的几个术语,但唯一相似的是http://www.cocoachina.com/bbs/read.php?tid-1726269.html ,我使用了谷歌翻译,一个人说:“主要是navigantionBarItem图片和文字位置偏移造成的”。

As I said the view was built in IB with a normal Navigation Controller, no offset in the button.正如我所说,视图是在带有普通导航控制器的 IB 中构建的,按钮中没有偏移。 The only difference with other similar viewControllers that work fine is the right navBarButton that is shown in case 1 but not in case 2 with the next code in viewDidLoad:与其他类似的工作正常的 viewController 的唯一区别是在情况 1 中显示的右侧导航栏按钮,但在 viewDidLoad 中的下一个代码中没有显示在情况 2 中:

if (self.fromAppDelegate) {
        self.doneButton.title = @"Cerrar";
        self.doneButton.enabled = YES;
    } else self.doneButton.enabled = NO;

I'm sure its gonna be an easy solution but right now I can't find it.我相信它会是一个简单的解决方案,但现在我找不到它。 I hope someone can help me.我希望有一个人可以帮助我。

OK, when I was checking the configuration for the button in IB, I noticed that its width (Size Inspector) was zero.好的,当我在 IB 中检查按钮的配置时,我注意到它的宽度(尺寸检查器)为零。 I changed it to 80 so, the button shows now in the preview.我将其更改为 80,因此该按钮现在显示在预览中。 I also, in Attributes Inspector, changed it from Custom system item to Done and in code added the next line for the else statement:我还在 Attributes Inspector 中将其从 Custom system item 更改为 Done 并在代码中为 else 语句添加了下一行:

self.doneButton.title = @"";

It worked, the app didn't crash anymore, but the button, if not enabled, was visible as Done all the time which is not what I want (the code above didn't work because it was set as System Button, duh).它起作用了,该应用程序不再崩溃,但是如果未启用该按钮,则始终显示为“完成”,这不是我想要的(上面的代码不起作用,因为它被设置为系统按钮,废话) . So, I change it back to Custom and delete the default title aaaand... everything was as before (check image in the question), but the app still works.所以,我将它改回自定义并删除默认标题 aaaand...一切都和以前一样(检查问题中的图片),但该应用程序仍然有效。 What?什么? Well, not everything was as before: the code above was the only change.好吧,并非一切都像以前一样:上面的代码是唯一的变化。 If I commented the line, the app crashes again.如果我评论该行,应用程序将再次崩溃。

I don't know if it's a bug or a new requirement, but I hope it useful for someone (I knew the answer was gonna be easy).我不知道这是错误还是新要求,但我希望它对某人有用(我知道答案很简单)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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