gpt4 book ai didi

ios - 向后滑动 iOS 7 时让 UIKeyboard 保持可见

转载 作者:可可西里 更新时间:2023-11-01 03:32:21 27 4
gpt4 key购买 nike

我有一个可以使用新的 interactivePopGestureRecognizer 弹出的 View Controller 。如果存在键盘并且滑动动画开始,则键盘不会随 View 移动。我看过这个question并在我的 View Controller 中这样实现它,它被解雇了

-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];

[self.transitionCoordinator animateAlongsideTransitionInView:self.aTextInputView.keyboardSuperView animation:^(id<UIViewControllerTransitionCoordinatorContext> context) {

CGRect frame = self.aTextInputView.keyboardSuperView.frame;
frame.origin.x = self.view.frame.size.width;

self.aTextInputView.keyboardSuperView.frame = frame;

} completion:nil];
}

现在,当 View 动画消失时,我得到的是键盘动画离开屏幕到 320 的 x 点,这与我设置的一样有意义,我的问题是如何让键盘与向后滑动?

更新

对于任何在 View 消失时看到奇怪动画的人,您可以通过这样做来移除键盘。

[self.transitionCoordinator notifyWhenInteractionEndsUsingBlock:^(id<UIViewControllerTransitionCoordinatorContext> context){
if (![context isCancelled]) {
[keyboardSuperview removeFromSuperview];
}
}];

最佳答案

你的代码片段中有很多自定义代码,如果我错了请纠正我,但你似乎有不正确的 self.aTextInputView.keyboardSuperView

仔细检查它不是nil。如果是,则您忘记添加 inputAccessoryView

这是没有任何扩展的完整代码片段:

- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
UIView *keyboardSuperview = self.textField.inputAccessoryView.superview;
[self.transitionCoordinator animateAlongsideTransitionInView:keyboardSuperview
animation:
^(id<UIViewControllerTransitionCoordinatorContext> context) {
CGRect keyboardFrame = keyboardSuperview.frame;
keyboardFrame.origin.x = self.view.bounds.size.width;
keyboardSuperview.frame = keyboardFrame;
}
completion:nil];
}

- (void)viewDidLoad
{
[super viewDidLoad];
self.textField.inputAccessoryView = [[UIView alloc] init];
}

关于ios - 向后滑动 iOS 7 时让 UIKeyboard 保持可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21929009/

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