ios - 显示键盘时 UIAlertView 消息未正确显示

标签 ios cocoa-touch ios7 keyboard uialertview

UIAlertView 消息在编辑其中的文本字段时(显示键盘时)无法正确显示。它是这样的: enter image description here

当键盘不存在时: enter image description here

这是创建警报 View 的代码:

        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"Title"
                                  message:@"Enter a name for your recipe"
                                  delegate:self
                                  cancelButtonTitle:@"Cancel"
                                  otherButtonTitles:@"OK", nil];
        [alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];
        [alertView show];

有没有办法改变 View 的某些组件的大小,以便在显示键盘时它能正确地适合屏幕?

编辑:我刚刚发现当键盘出现时警报 View 变得可滚动。因此,如果向下滚动,您可以看到该消息。但是我没有注意到第一次弹出警报 View ,其他用户可能也没有。现在,我正在使用 Visput 建议的内容。

最佳答案

这是 iOS 的标准行为。在横向模式下创建新相册时,您可以在“照片”应用程序中看到相同的布局。
我认为在这种情况下最好的方法是:将所有文本放置到 messagetitle 设置为 nil。
在你的情况下:

UIAlertView *alertView = [[UIAlertView alloc]
                              initWithTitle:nil
                              message:@"Title: Enter a name for your recipe"
                              delegate:self
                              cancelButtonTitle:@"Cancel"
                              otherButtonTitles:@"OK", nil];

关于ios - 显示键盘时 UIAlertView 消息未正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23194096/

相关文章:

ios - EXC_BREAKPOINT (code=EXC_I386_BPT, subcode 0x0) with 32-bit simulator

ios - AVURLAsset 未加载(.mov 文件)

c++ - 将 C++ 类的实例转换为 NSObject,然后添加到 NSMutableArray

ios - 无法关闭从 iOS 8 中的 UIDocumentInteractionController 调用的电子邮件表

ios - 未设置表格的动态高度

ios - 重置 iOS 应用角标(Badge)

ios - UINavigationBar 子类上的 drawRect 使状态栏变黑

iOS:shouldChangeCharactersInRange 返回旧结果

ios - 重复和取消 UILocalNotification

ios - TypeKit vs NSAttributedString - 在创建样式标签时,我可以使用 TextKit 代替 NSAttributedString 吗?