Hide gray box in UiSplitView when animating to PrimaryHidden from PrimaryOverlay in iPhone

此生再无相见时 提交于 2019-12-01 12:11:58
David H

After banging my head on this for several days, I found a related answer that showed the culprit is the _UIPopoverSlidingChromeView view. The only solution I could find is similar to the solution of the above topic: to hide that view during the animation.

var foundChrome = false
var view: UIView! = self.view
var popView: UIView!

let displayModeButton = self.splitViewController!.displayModeButtonItem()

while view != nil {
   //print("View: ", Mirror(reflecting: view).subjectType, " frame: \(view.frame)")

   if let sv = view {
      if Mirror(reflecting: sv).description.containsString("Popover") { // _UIPopoverView
         for v in sv.subviews {
            //print("SV: ", Mirror(reflecting: v).subjectType, " frame: \(v.frame)")
            if Mirror(reflecting: v).description.containsString("Chrome") {
               foundChrome = true
               popView = v
               popView.hidden = true
               break
            }
         }
         if foundChrome { break }
      }
   }
   view = view.superview
}
if foundChrome {
   let duration: NSTimeInterval = 2.0
   UIView.animateWithDuration(duration, animations: { () -> Void in
      UIApplication.sharedApplication().sendAction(displayModeButton.action, to: displayModeButton.target, from: nil, forEvent: nil)
   })
   // must do this separately, doing in a completion block doesn't work, as it takes affect too soon
   let t = dispatch_time(DISPATCH_TIME_NOW, Int64(duration * NSTimeInterval(NSEC_PER_SEC)))
   dispatch_after(t, dispatch_get_main_queue()) {
      popView.hidden = false
   }
}

I realize this is somewhat esoteric, but if you experience the problem you will be happy for any way to work around it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!