繁体   English   中英

在 XCode 9 上更新 ObjC 应用程序

[英]Updating ObjC app on XCode 9

我最近在 XCode 9 上更新了我们的 ObjC 应用程序。一切正常(我什至更新到 iPhone X 新布局),只是其中一个视图控制器(内置于 IB)出现问题。 这个 viewController 显示了一个带有新闻的 tableView,可以从 2 个来源访问:

  1. 来自 appDelegate 如果推送通知通知新消息。 在这种情况下,右侧的 navBarButton 未隐藏,因此用户可以关闭视图
  2. 从使用普通后退按钮的特定部分

当我尝试从第二种情况打开 viewController 时,应用程序崩溃并显示下一条消息:

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 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 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的(层次)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:动画:] + 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主+ 111 58 libdyld .dylib 0x00000001 0ac32d81 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 中构建的,按钮中没有偏移。 与其他类似的工作正常的 viewController 的唯一区别是在情况 1 中显示的右侧导航栏按钮,但在 viewDidLoad 中的下一个代码中没有显示在情况 2 中:

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

我相信它会是一个简单的解决方案,但现在我找不到它。 我希望有一个人可以帮助我。

好的,当我在 IB 中检查按钮的配置时,我注意到它的宽度(尺寸检查器)为零。 我将其更改为 80,因此该按钮现在显示在预览中。 我还在 Attributes Inspector 中将其从 Custom system item 更改为 Done 并在代码中为 else 语句添加了下一行:

self.doneButton.title = @"";

它起作用了,该应用程序不再崩溃,但是如果未启用该按钮,则始终显示为“完成”,这不是我想要的(上面的代码不起作用,因为它被设置为系统按钮,废话) . 所以,我将它改回自定义并删除默认标题 aaaand...一切都和以前一样(检查问题中的图片),但该应用程序仍然有效。 什么? 好吧,并非一切都像以前一样:上面的代码是唯一的变化。 如果我评论该行,应用程序将再次崩溃。

我不知道这是错误还是新要求,但我希望它对某人有用(我知道答案很简单)。

暂无
暂无

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

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