经过几天的努力,我找到了一个相关的答案,表明罪魁祸首是_UIPopoverSlidingChromeView
观点。我能找到的唯一解决方案类似于上述主题的解决方案:在动画期间隐藏该视图。
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
}
}
我意识到这有点深奥,但如果你遇到这个问题,你会很高兴以任何方式解决它。