0

我正在检查文本字段值。如果它将为空,则焦点将保留在同一文本字段中,否则它将移动到另一个文本字段。所以,这是我实现的一些代码。但是,目前它不起作用。

- (IBAction)verifyDisplayName:(id)sender {
        if ([_displayName.text isEqualToString:@""])
        {
            [_displayNameField becomeFirstResponder];
        }
        else
        {
            _displayNameVerified = YES;
        }
}  

请给我与我的查询相关的建议。

谢谢

4

1 回答 1

0

Check variables; Here you checking _displayName.text Next you are setting [_displayNameField becomeFirstResponder];

I think it would be better to use smthg like this:

_displayName.text.length > 0 //In this case you can validate length of your name, if conditions will change

Hope it helps

于 2016-04-21T07:59:51.760 回答