【发布时间】:2009-12-16 01:32:20
【问题描述】:
我目前正在为 iPhone 开发应用程序。有一个屏幕要求用户以文本格式输入他们的数据,但只需单击“提交”按钮即可轻松跳过。有没有办法让这些文本字段成为必需?
【问题讨论】:
-
如果您想要任何类型的答案,您将不得不比这更具体。
标签: iphone objective-c text field
我目前正在为 iPhone 开发应用程序。有一个屏幕要求用户以文本格式输入他们的数据,但只需单击“提交”按钮即可轻松跳过。有没有办法让这些文本字段成为必需?
【问题讨论】:
标签: iphone objective-c text field
您是否尝试过停用按钮,除非文本字段中有内容?
【讨论】:
你可以告诉按钮进程密切关注文本字段,这样如果文本字段为空,按钮就不会处理这样的功能
-(IBAction) buttonPressed:(id) sender
{
//----this will process the button function if the textfield is not empty
if(textField.text != @"")
{
>>> do the process <<<
}
else
//----this will show an alert message when the user tries to click button without filling the textfield
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"error"
message:@"please fill the information first"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
【讨论】: