从iPhone中的PrimaryOverlay动画到PrimaryHidden时,隐藏UiSplitView中的灰色框 [英] Hide gray box in UiSplitView when animating to PrimaryHidden from PrimaryOverlay in iPhone
问题描述
这里有很多答案描述如何以编程方式为主分割视图设置动画:
There are numerous answers here that describe how to programmatically animate the primary split view:
let addButton = self.splitViewController!.displayModeButtonItem()
UIApplication.sharedApplication().sendAction(addButton.action, to: addButton.target, from: nil, forEvent: nil)
在iPad上这非常有用!但是在iPhone上有一个令人烦恼的灰色盒子,它可以追踪主视图。通过将该动作包装在UIView.animate块中,可以非常清楚地看到它:
On an iPad this works wonderfully! But on an iPhone there is this annoying gray box that trails the primary view. By wrapping that action in a UIView.animate block, its possible to see it quite clearly:
当您通过点击详细视图实际关闭主视图时,该框几乎不可见,但是当您以编程方式关闭它时真的很烦人。
The box is hardly visible when you actually dismiss the primary view by tapping over the detail view, but is really annoying when you programmatically dismiss it.
如何删除这个令人讨厌的视图?
How can I remove this annoying view?
推荐答案
在我敲了几天之后,我找到了一个< a href =https://stackoverflow.com/q/26164982/1633251>相关答案显示罪魁祸首是 _UIPopoverSlidingChromeView
视图。我能找到的唯一解决方案类似于上述主题的解决方案:在动画期间隐藏该视图。
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.
这篇关于从iPhone中的PrimaryOverlay动画到PrimaryHidden时,隐藏UiSplitView中的灰色框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!