2016-11-16 91 views
0

我正在使用具有3個視圖的堆棧視圖,一個是具有集羣圖標的GMS mapview,另外兩個視圖是具有多個嵌套堆棧視圖的視圖。當我在地圖視圖上選擇一個圖標時,它將在動畫塊中取消隱藏其他兩個視圖中的一個或兩個。iOS Autolayout致命錯誤NSInternalInconsistencyException在取消隱藏視圖時

有時並不總是當我點擊在地圖視圖上選擇一個集羣圖標時,它會導致以下崩潰錯誤。請參閱界面構建器中視圖上的附加圖像。每個標籤都使用高度約束,優先級爲@ 999,以滿足堆棧視圖的不明確性。

Story board interface builder.

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempt to rebuild engine with a pending list of constraints to remove.' 
*** First throw call stack: 
(
    0 CoreFoundation      0x0000000111c5a34b __exceptionPreprocess + 171 
    1 libobjc.A.dylib      0x00000001116bb21e objc_exception_throw + 48 
    2 CoreFoundation      0x0000000111c5e442 +[NSException raise:format:arguments:] + 98 
    3 Foundation       0x0000000111251e4d -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195 
    4 Foundation       0x00000001113b64eb -[NSISEngine rebuildFromConstraints] + 195 
    5 Foundation       0x00000001111dde1a -[NSISEngine optimize] + 121 
    6 Foundation       0x00000001113b3f20 -[NSISEngine performPendingChangeNotifications] + 84 
    7 UIKit        0x000000011030bbef -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededPostponeVariableChangeNotifications:] + 1357 
    8 UIKit        0x000000011030690a -[UIView(AdditionalLayoutSupport) _systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:hasIntentionallyCollapsedHeight:] + 294 
    9 UIKit        0x000000010ff5c51c -[UIStackView _systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:hasIntentionallyCollapsedHeight:] + 180 
    10 UIKit        0x000000010ff5ccb5 -[UIStackView _proportionalFillLengthForOrderedArrangement:relevantParentAxis:] + 112 
    11 UIKit        0x0000000110318302 -[_UIOrderedLayoutArrangement _setUpDimensionConstraintForItem:referenceItem:atIndex:] + 406 
    12 UIKit        0x00000001103191ad -[_UIOrderedLayoutArrangement _insertIndividualGuidesAndConstraintsAsNecessary] + 2215 
    13 UIKit        0x0000000110319f90 -[_UIOrderedLayoutArrangement _updateArrangementConstraints] + 1450 
    14 UIKit        0x000000011030c3e5 -[UIView(AdditionalLayoutSupport) _handleLayoutArrangementConstraintsIfNecessary] + 198 
    15 UIKit        0x000000011030c4c9 -[UIView(AdditionalLayoutSupport) _updateSystemConstraints] + 53 
    16 UIKit        0x000000010ff5c40d __32-[UIStackView updateConstraints]_block_invoke + 47 
    17 UIKit        0x000000011030aa9b -[UIView(AdditionalLayoutSupport) _withUnsatisfiableConstraintsLoggingSuspendedIfEngineDelegateExists:] + 117 
    18 UIKit        0x000000010ff5c3ce -[UIStackView updateConstraints] + 85 
    19 UIKit        0x000000011030af3e -[UIView(AdditionalLayoutSupport) _sendUpdateConstraintsIfNecessaryForSecondPass:] + 161 
    20 UIKit        0x000000011030b39d -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 860 
    21 UIKit        0x000000011030b2fa -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 697 
    22 UIKit        0x000000011030b2fa -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 697 
    23 UIKit        0x000000011030b2fa -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 697 
    24 UIKit        0x000000011030b2fa -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 697 
    25 UIKit        0x000000011030b2fa -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 697 
    26 UIKit        0x000000011030b2fa -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 697 
    27 UIKit        0x000000011030b2fa -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 697 
    28 Foundation       0x00000001111d7bd0 -[NSISEngine withBehaviors:performModifications:] + 155 
    29 UIKit        0x000000011030bc71 __97-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededPostponeVariableChangeNotifications:]_block_invoke + 91 
    30 UIKit        0x000000011030aa9b -[UIView(AdditionalLayoutSupport) _withUnsatisfiableConstraintsLoggingSuspendedIfEngineDelegateExists:] + 117 
    31 UIKit        0x000000011030b757 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededPostponeVariableChangeNotifications:] + 181 
    32 UIKit        0x000000011030c84d -[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeededPostponeVariableChangeNotifications:] + 356 
    33 UIKit        0x000000010f9e5ad3 -[UIView(Hierarchy) layoutBelowIfNeeded] + 198 
    34 IslandWeatherNet     0x000000010cd3db42 _TFFFC16IslandWeatherNet17MapViewController16toggleSummaryBarFPs9AnyObject_T_L_17toggleSummaryViewFT_T_U_FT_T_ + 386 
    35 IslandWeatherNet     0x000000010cd186f7 _TTRXFo___XFdCb___ + 39 
    36 UIKit        0x000000010f9eda6d +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 581 
    37 UIKit        0x000000010f9ede0f +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:] + 187 
    38 IslandWeatherNet     0x000000010cd3d86c _TFFC16IslandWeatherNet17MapViewController16toggleSummaryBarFPs9AnyObject_T_L_17toggleSummaryViewfT_T_ + 1660 
    39 IslandWeatherNet     0x000000010cd3d10c _TFC16IslandWeatherNet17MapViewController16toggleSummaryBarfPs9AnyObject_T_ + 588 
    40 IslandWeatherNet     0x000000010cd3c22f _TFC16IslandWeatherNet17MapViewController16toggleStationBarfPs9AnyObject_T_ + 1247 
    41 IslandWeatherNet     0x000000010cd55aa9 _TFC16IslandWeatherNet17MapViewController14clusterManagerfTCSo17GMUClusterManager6didTapPSo14GMUClusterItem__T_ + 857 
    42 IslandWeatherNet     0x000000010cd55d9b _TToFC16IslandWeatherNet17MapViewController14clusterManagerfTCSo17GMUClusterManager6didTapPSo14GMUClusterItem__T_ + 75 
    43 IslandWeatherNet     0x000000010ccd7635 -[GMUClusterManager mapView:didTapMarker:] + 677 
    44 CoreFoundation      0x0000000111be105c __invoking___ + 140 
    45 CoreFoundation      0x0000000111be0ee1 -[NSInvocation invoke] + 289 
    46 CoreFoundation      0x0000000111bf8ed6 -[NSInvocation invokeWithTarget:] + 54 
    47 IslandWeatherNet     0x000000010cdf9d3b -[GMSDelegateForward forwardInvocation:] + 102 
    48 CoreFoundation      0x0000000111bdfa2e ___forwarding___ + 526 
    49 CoreFoundation      0x0000000111bdf798 _CF_forwarding_prep_0 + 120 
    50 IslandWeatherNet     0x000000010cd6c766 -[GMSMapView didTapMarker:] + 59 
    51 IslandWeatherNet     0x000000010cdb4812 -[GMSMarker wasTapped] + 57 
    52 UIKit        0x000000010fe75e41 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 57 
    53 UIKit        0x000000010fe7dbe0 _UIGestureRecognizerSendTargetActions + 109 
    54 UIKit        0x000000010fe7b6af _UIGestureRecognizerSendActions + 227 
    55 UIKit        0x000000010fe7a93b -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 891 
    56 UIKit        0x000000010fe66a0e _UIGestureEnvironmentUpdate + 1395 
    57 CoreFoundation      0x0000000111bfee17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23 
    58 CoreFoundation      0x0000000111bfed87 __CFRunLoopDoObservers + 391 
    59 CoreFoundation      0x0000000111be3b9e __CFRunLoopRun + 1198 
    60 CoreFoundation      0x0000000111be3494 CFRunLoopRunSpecific + 420 
    61 GraphicsServices     0x000000011592ba6f GSEventRunModal + 161 
    62 UIKit        0x000000010f933964 UIApplicationMain + 159 
    63 IslandWeatherNet     0x000000010ccfb78f main + 111 
    64 libdyld.dylib      0x0000000112b8068d start + 1 
    65 ???         0x0000000000000001 0x0 + 1 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 

當的圖標上的MapView它將調用其包含以下的方法分接。

mapView.animate(toLocation: station.position) 
      toggleStationBar(clusterManager) 


@IBAction func stationMoreLessToggleButton(_ sender: AnyObject) { 
     stationMoreLessButton.setTitle(moreStationInfo ? " L " : " M ", for: UIControlState()) 

     func moreInfo() { 
      UIView.animate(withDuration: 1.0, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 10.0, options: [.curveEaseOut], animations: { 
       self.uvIndexInsolationStackView.isHidden = false 
       self.uvIndexInsolationStackView.alpha = 1.0 
       self.distanceRainStackView.isHidden = false 
       self.distanceRainStackView.alpha = 1.0 
       self.timeContainer.isHidden = false 
       self.timeContainer.alpha = 1.0 
       self.stationStackView.layoutIfNeeded() 
      }, completion: nil) 
     } 
     func lessInfo() { 
      UIView.animate(withDuration: 1.0, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 10.0, options: [.curveEaseOut], animations: { 
       self.timeContainer.isHidden = true 
       self.timeContainer.alpha = 0.0 
       self.distanceRainStackView.isHidden = true 
       self.distanceRainStackView.alpha = 0.0 
       self.uvIndexInsolationStackView.isHidden = true 
       self.uvIndexInsolationStackView.alpha = 0.0 
       self.stationStackView.layoutIfNeeded() 
      }, completion: nil) 
     } 
     if moreStationInfo { 
      if isSummaryOpen { 
       toggleSummaryBar(moreStationInfo as AnyObject) 
      } 
      moreInfo() 
     } else { 
      lessInfo() 
     } 
     moreStationInfo = !moreStationInfo 
    } 

    @IBAction func toggleStationBar(_ sender: AnyObject) { 

     func toggleView() { 
      isBarOpen = !isBarOpen 
      stationCloseButton.setTitle(isBarOpen ? " X " : " + ", for: UIControlState()) 
      stationView.isHidden = isBarOpen ? false : true 

      UIView.animate(withDuration: 1.0, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 10.0, options: [.curveEaseOut], animations: { 
       self.stationView.alpha = self.isBarOpen ? 1.0 : 0.0 
       self.view.layoutIfNeeded() 
       }, completion: nil) 
     } 
     if sender as! NSObject == clusterManager { 
      if isBarOpen { 
       //Animate fields but not title. 
       UIView.animate(withDuration: 0.5, delay: 0, options: [.transitionFlipFromRight], animations: { 
        self.updateInfoBarLabels(observation: self.selectedObservation) 
        }, completion: nil) 
      } else { 
       toggleView() 
       updateInfoBarLabels(observation: selectedObservation) 
       if isSummaryOpen { 
        toggleSummaryBar(clusterManager) 
       } 
      } 
     } else if sender as! NSObject == stationCloseButton { 
      toggleView() 
     } else if sender as! NSObject == mapView { 
      if isBarOpen { 
       toggleView() 
      } else { 
       return 
      } 
     } 
    } 


    @IBAction func toggleSummaryBar(_ sender: AnyObject) { 

     func toggleSummaryView() { 
      isSummaryOpen = !isSummaryOpen 
      toggleSummaryButton.setTitle(isSummaryOpen ? " - " : " + ", for: UIControlState()) 
      if summaryView.isHidden { 
       summaryView.isHidden = false 
      } 

      UIView.animate(withDuration: 1.0, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 10.0, options: [.curveEaseOut], animations: { 
       self.summaryListStackView.isHidden = self.isSummaryOpen ? false : true 
       self.summaryView.layoutIfNeeded() 
      }, completion: nil) 
      self.summaryListStackView.alpha = self.isSummaryOpen ? 1.0 : 0.0 // Fixes views hanging around towards end of animation bounce. 
     } 
     if sender as! NSObject == toggleSummaryButton { 
      if !moreStationInfo { 
       stationMoreLessToggleButton(toggleSummaryButton) 
      } 
      toggleSummaryView() 
     } else if sender as! NSObject == clusterManager { 
      toggleSummaryView() 
     } else { 
      summaryView.isHidden = false 
      toggleSummaryView() 
     } 

    } 

回答

0

我發現了藍綠色「站名」視圖的高度,使其高度約束優先級爲1000.將其更改爲999修復了問題。

垂直堆棧視圖的所有其他高度約束都具有999的優先級,因此堆棧視圖可以在動畫期間摺疊視圖。

相關問題