【问题标题】:iOS keyboard dismiss and then immediately showiOS键盘关闭然后立即显示
【发布时间】:2014-09-26 22:10:57
【问题描述】:

我有 UIViewController 和 UITextView。这个 TextView 总是 firstResponder。

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self createBottomBar];
    _textView.delegate = self;
    [_textView becomeFirstResponder];
}   

当用户点击“视频”按钮时,我的应用会显示带有文本字段的 UIAlertView

- (IBAction)showVideoPicker:(id)sender {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:_(@"Link to movie")
        message:_(@"Insert a link to YouTube clip or a Coub")
        delegate:self
        cancelButtonTitle:_(@"Cancel")
        otherButtonTitles:_(@"Attach"), nil];
    alert.alertViewStyle = UIAlertViewStylePlainTextInput;
    [alert show];
}

当用户点击“附加”按钮时,警报解除和键盘解除,然后立即显示。我想要另一种情况:键盘不会关闭,因为文本视图应该始终是第一响应者。只是 UIAlertView 关闭键盘关闭/显示动画。

更多了解请看 gif here(没有足够的声望发布图片)。对不起我的英语。

【问题讨论】:

    标签: ios keyboard uitextview uialertview


    【解决方案1】:

    您是否尝试通过UIAlertView 委托在“附加”按钮上设置第一响应者?这是这里唯一的方法:

    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
        if (buttonIndex == 1) [_textView becomeFirstResponder];
    }
    

    键盘可能会或可能不会跳动一点,但这就是我们所拥有的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-02
      • 1970-01-01
      • 2017-11-21
      • 2016-03-19
      • 1970-01-01
      • 1970-01-01
      • 2020-08-04
      • 1970-01-01
      相关资源
      最近更新 更多