UITextField在UIAlertView中的替代方案? [英] UITextField in UIAlertView alternative?

查看:80
本文介绍了UITextField在UIAlertView中的替代方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要用户快速输入。我知道我可以把UITextField在UIAlertView,但它是一种黑客。有没有官方/替代方法来做到这一点?

I want a quick input from a user. I know I can put a UITextField in UIAlertView but it's sort of a "hack". Is there an official/alternative way to do this?

这是一个非常惊讶的是,没有控制这种典型的情况。

It's pretty surprising that there's no control for such a typical scenario.

感谢

更新:
尝试EGOTextFieldAlertView,但结果是:

UPDATE: Tried EGOTextFieldAlertView but here's the result:

和代码:

   EGOTextFieldAlertView *alert = [[EGOTextFieldAlertView alloc] initWithTitle:@"Enter the group name" 
                                                                        message:nil 
                                                                       delegate:self 
                                                              cancelButtonTitle:@"Cancel" 
                                                              otherButtonTitles:@"OK", nil];
    [alert addTextFieldWithLabel:@"Name"];
    [alert show];
    [alert release];


推荐答案

如果你愿意使用iOS 5,不再是黑客。 UIAlertView现在有一个 alertViewStyle 属性,当设置为 UIAlertViewStylePlainTextInput 时,会在警报中添加一个文本字段用 - [UIAlertView textFieldAtIndex:] 检索

If you're willing to require iOS 5 then it's no longer a hack. UIAlertView now has a alertViewStyle property which, when set to UIAlertViewStylePlainTextInput, adds a single text field to the alert that you can retrieve with -[UIAlertView textFieldAtIndex:].

如果您仍然需要4.3或更早版本,官方的方式来做到这一点,它真的是一个大的黑客,与调用SPI一样。

If you still require 4.3 or earlier, then no, there's no official way to do this and it really is a big "hack" that's on par with calling SPI.

这篇关于UITextField在UIAlertView中的替代方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆