我有一个目标操作,当按下按钮时,我验证UITextField
:
// Get the text from the UITextField
NSString *nameStr = _name.text;
_name.rightView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"error.png"]];
[self.view addSubview:_name];
if (nameStr.length == 0)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Invalid Name"
message:@"You must enter a name."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
我像这样UITextField
添加到视图中viewDidLoad
:
[self.view addSubview:_name];
如何使 rightViewUIImageView
出现?