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/