Bạn có thể phát hiện các lần vuốt bằng cách sử dụng UISwipeGestureRecognizer
. Tôi đang sử dụng nó trên UIWebView:
Trong viewDidLoad tôi có:
let swipeUp = UISwipeGestureRecognizer(target: self, action: "didSwipe")
let swipeDown = UISwipeGestureRecognizer(target: self, action: "didSwipe")
swipeUp.direction = UISwipeGestureRecognizerDirection.Up
swipeDown.direction = UISwipeGestureRecognizerDirection.Down
webView.addGestureRecognizer(swipeUp)
webView.addGestureRecognizer(swipeDown)
navigationController?.hidesBarsOnSwipe = true
Tôi cũng có một phần mở rộng để viewController tôi, gọi WebViewViewController:
extension WebViewViewController {
override func prefersStatusBarHidden() -> Bool {
return hideStatusBar
}
override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation {
return UIStatusBarAnimation.Slide
}
}
Trên một mức độ lớp trong WebViewViewController của tôi Tôi cũng có:
var hideStatusBar = false
func didSwipe() {
hideStatusBar = true
}
hey, đã bao giờ bạn tìm hiểu làm thế nào để làm điều này? cảm ơn! – dot
Rất tiếc, bạn có thể thêm +1 không? – jmcastel
Hãy xem câu hỏi của tôi: http://stackoverflow.com/questions/25870382/how-to-prevent-status-bar-from-overlapping-content-with-hidesbarsonswipe-set-on –