【问题标题】:making a text field required in objective-c在objective-c中制作一个需要的文本字段
【发布时间】:2009-12-16 01:32:20
【问题描述】:

我目前正在为 iPhone 开发应用程序。有一个屏幕要求用户以文本格式输入他们的数据,但只需单击“提交”按钮即可轻松跳过。有没有办法让这些文本字段成为必需?

【问题讨论】:

  • 如果您想要任何类型的答案,您将不得不比这更具体。

标签: iphone objective-c text field


【解决方案1】:

您是否尝试过停用按钮,除非文本字段中有内容?

【讨论】:

    【解决方案2】:

    你可以告诉按钮进程密切关注文本字段,这样如果文本字段为空,按钮就不会处理这样的功能

    -(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];
       }
    }
    

    【讨论】:

    • Shift、“y”和“o”键卡住了?
    猜你喜欢
    • 1970-01-01
    • 2019-01-10
    • 2011-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多