簡體   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