iphone - 如何弹出文本字段

标签 iphone ios4 sdk

我的应用程序中有一个包含许多标签的 View 和一个带有一些按钮的工具栏。我想在按下按钮时同时编辑所有标签。我认为这可能是一种“弹出”文本输入并同时显示键盘的方法。哪种方法最干净? 谢谢

最佳答案

http://discussions.apple.com/thread.jspa?messageID=8445879

或者。我是这样做的:

UIAlertView *prompt = [[UIAlertView alloc] initWithTitle:@"Please enter your name:"
                                                 message:@"\n\n"
                                                delegate:self
                                       cancelButtonTitle:@"Cancel"
                                       otherButtonTitles:@"Enter", nil];

textField = [[UITextField alloc] initWithFrame:CGRectMake(12, 50, 260, 25)];
[textField setBackgroundColor:[UIColor whiteColor]];
[textField setPlaceholder:@"Name for message"];
[prompt addSubview:textField];
[textField release];

// show the dialog box
[prompt show];
[prompt release];

// set cursor and show keyboard
[textField becomeFirstResponder];

然后在 UIAlertView 委托(delegate)方法中,您从 textField.text 读取内容:-)

关于iphone - 如何弹出文本字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4467379/

相关文章:

iphone - 从 ASIHTTPRequest 转换为 AFNetworking

iphone - [NSMutableURLRequest 发布] : message sent to deallocated instance

ios4 - 在 Xcode 4 中链接静态库的问题

iphone - 当位置发生变化并且我的应用程序处于后台时,我可以收到本地通知吗?

iphone - 如何在 CGAffineTransform 中传递值 Make

java.lang.NoClassDefFoundError : how do I fix this error? 错误

ios - 集成适用于 iOS 的 PubNub WebRTC SDK

iPhone 应用程序无法在旧设备上运行(3G、3GS...)

iphone - 如何使用Apple80211确定安全类型,例如WPA、WPA2、WEP?

iPhone : hide a scopeBar from a searchBar