2016-11-16 40 views
0

私は3つのビューを持つスタックビューを使用しています.1つはクラスタアイコンを含むGMSマップビューで、他の2つのビューは複数のネストされたスタックビューを持つビューです。マップビューでアイコンを選択すると、アニメーションブロック内の他の2つのビューの一方または両方が再表示されます。iOS Autolayoutの致命的なエラーNSInternalInconsistencyExceptionビューを表示していないとき

マップビューでクラスタアイコンをタップして選択すると、以下のクラッシュエラーが発生することがあります。インタフェースビルダーのビューの添付イメージを参照してください。各ラベルはスタックビューとのあいまいさを満たすために高さ制約を999の優先度で使用しています。アイコンがMapViewの上でタップすると

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.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

私は999の問題を修正し、これを変更する1000の高さ制約の優先順位を持つように「駅名」ビューを色ティールの高さを発見しました。

垂直スタックビューの他のすべての高さ制約には999の優先度があり、スタックビューはアニメーション中にビューを折りたたむことができます。