我的应用程序中有一个包含许多标签的 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/