gpt4 book ai didi

iOS - 使用 CustomGestureRecognizer 设置键盘位置

转载 作者:行者123 更新时间:2023-11-30 13:18:57 25 4
gpt4 key购买 nike

“iMessage”和“Facebook Messenger”等应用程序允许用户通过向下滑动将键盘移出屏幕。我可以使用 CustomGestureRecognizer 设置其他 View 在屏幕上移动。 (下面的片段)

    override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent) {

let window = view?.window
if state == .Failed {
return
} else if let loc = touches.first?.locationInView(window) {
displacement = loc.y - swipeStartingY
delegatePass?.didSlowSwipe(displacement)
state = .Changed
}
super.touchesMoved(touches, withEvent: event)
}

How do these apps set the frame.origin.y of the keyboard to move it down and off the screen?

--已解决

How do I get my UITextView that sits above the keyboard to follow the keyboard, now that scrollView.keyboardDismissMode = .Interactive?

最佳答案

一旦收到来自手势识别器的回调,循环遍历所有 View 以查找哪个 View 是响应者(也称为当前正在编辑的 View )并调用方法“view.endEditing(true)”以使键盘解雇。

Facebook Messenger 应用程序刚刚结束文本字段的编辑,导致键盘关闭。

关于iOS - 使用 CustomGestureRecognizer 设置键盘位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37949767/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com