ios - How to recognize the interactivePopGestureRecognizer is successfully proceed when swipe to pop viewController? -
i want clean properties when user swipe page pop viewcontroller, make works same tapping button.
i try following code, fails because not every swipe successful every time. swipes pop might fail because gesture cancelled.
and can not find enough delegate in uigesturerecognizer (to find touchesended
). neither can use target action because action called many times.
func viewwillappear(_ animated: bool) { self.navigationcontroller.interactivepopgesturerecognizer.delegate = self } func gesturerecognizershouldbegin(_ gesturerecognizer: uigesturerecognizer) -> bool { viewmodel.gobackpage(isswipeback: true) return true }
how solve trigger backbuttonpressed
in swipe pop viewcontroller @ right moment?
oh god, of @sam_m (https://stackoverflow.com/users/6739471/sam-m) 's comment, solved it!!
override func viewwilldisappear(_ animated: bool) { super.viewwilldisappear(animated) if isswipepop { viewmodel.gobackpage(withpopviewcontroller: true) } } func gesturerecognizershouldbegin(_ gesturerecognizer: uigesturerecognizer) -> bool { switch gesturerecognizer.state { case .possible: isswipepop = true break case .began: isswipepop = true break case .changed: isswipepop = true break default: isswipepop = false break } return true }
Comments
Post a Comment