清除UITextField文本和图像

时间:2014-05-20 07:08:15

标签: ios ios7 uitextfield

我的UITextField

有错误代码
if (passwordStr.length == 0)
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Invalid Password"
                                                    message:@"You must enter a password."
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];
    [alert show];
    hasError = YES;

    [_password setRightViewMode:UITextFieldViewModeUnlessEditing];
    _password.rightView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"rsz_logoblack.png"]];

}

我想让代码稍后清除_password UITextfield(无文本)并删除正确的图片并将其恢复为默认Textfield

1 个答案:

答案 0 :(得分:0)

这样的东西?

_password.text = @"";
_password.rightView = nil;