折腾:
[已解决]iOS中进入页面后无故触发UIKeyboardWillShowNotification而显示键盘
期间,判断当前页面,是否显示完毕
即:是否已经进入:
viewWillAppear
或:
viewDidAppear
搜:
swift check view already show
swift check view already appear
ios – How to tell if UIViewController’s view is visible – Stack Overflow
swift check view appear
iphone – How to check if a specific UIViewController’s view is currently visible? – Stack Overflow
最后没找到。只能自己去手动定义一个变量去判断:
<code> var isViewDidAppear:Bool init(curContactItem:ContactItem){ self.isViewDidAppear = false } // override func viewDidDisappear(animated: Bool) { // super.viewDidDisappear(animated) // self.isViewDidAppear = false // } override func viewWillDisappear(animated: Bool) { super.viewWillDisappear(animated) self.isViewDidAppear = false } override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) self.isViewDidAppear = true } </code>
然后供后续判断:
<code> func textViewShouldBeginEditing(textView: UITextView) -> Bool { gLog.debug("self.inputTextView.isFirstResponder()=\(self.inputTextView.isFirstResponder()), self.view.isFirstResponder()=\(self.view.isFirstResponder()), self.isViewDidAppear=\(self.isViewDidAppear)") return self.isViewDidAppear } </code>
转载请注明:在路上 » [已解决]swift中判断当前页面是否显示完毕