【问题标题】:iOS - Keyboard hides UIAlertView with UITextfieldiOS - 键盘用 UITextfield 隐藏 UIAlertView
【发布时间】:2015-01-17 17:35:28
【问题描述】:

我有一个UIAlertView 和一个UITextField。我希望用户输入一些内容并点击OK。但是当键盘出现时,它隐藏了UIAlertView 的按钮。有没有办法让UIAlertView 在显示键盘时移动。或者只是将其向上移动,以便用户看到按钮?

这是我使用的代码:

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"title" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Other", nil] ;
alertView.tag = 2;
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
UITextField * alertTextField = [alertView textFieldAtIndex:0];
alertTextField.keyboardType = UIKeyboardTypePhonePad;
CGRect frame = alertView.frame;
frame.origin.y = -140;
alertView.frame = frame;
alertTextField.text = @"some text";
[alertView show];

【问题讨论】:

  • 嗨。我不知道警报视图是否可以自行定位,但也许您可以将其放入滚动视图中,当用户点击文本字段时,它只会滚动到您的可见区域。

标签: ios hide uialertview uikeyboard


【解决方案1】:

我不知道警报视图是否可以自行定位,但也许您可以将其放入滚动视图中,当用户点击文本字段时,它只会为您滚动到可见区域。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-10
    • 2013-01-12
    • 1970-01-01
    • 2022-01-23
    • 1970-01-01
    • 2016-05-30
    • 1970-01-01
    相关资源
    最近更新 更多