iphone - 如何检查 UITextfield 是否输入了数据?

标签 iphone ios uitextfield

uitextfield 的默认值是多少?
我需要使用消息实现登录页面警报“请输入两个字段”
如何实现检查用户名和密码文本字段是否填写的条件?

最佳答案

您的登录 View 将有一个用户名( txtUsername )和一个密码( txtPwd )文本字段。还有一个按钮( btnLogin )。

-(IBAction)Login:id(sender)  
{
if([txtUsername.text length] !=0 && [txtPwd.text length] !=0)
{
// Navigate to view controller you want to
}
else
{
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil message:@"please enter both the fields" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

[alertView show];                           
[alertView release];
}
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

    if (buttonIndex == 0) {

        //OK clicked

        //Do something

    } 
    else {

    }

}

关于iphone - 如何检查 UITextfield 是否输入了数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7187962/

相关文章:

iphone - 如何让 iPod 音乐在我的应用程序运行时播放?

iphone - 如何判断iphone第一次加载应用?

ios - 将 NSPredicate 添加到 Core Data 获取请求

iOS:处理文本字段/ View 交互和键盘移动的最稳定方式?

ios - 放弃文本字段 - 代码重用

iphone - 当 iPhone 中的 Appstore 上的应用程序版本更改时,sqlite 数据库更新

iphone - 如何在 Facebook 登录后返回应用程序?

android - 如何更改 react-native webview 的 font-family (font-family.ttf from assets)

ios - 从一个实体到多个实体的核心数据关系

objective-c - 在 UITextField 上显示过去的条目