我试图在我的应用程序中创建某种会员卡,基本上当输入正确的密码时,我希望它更改UIImageView的图像,但我无法使其工作,这里是部分代码:使用UIAlertViewStyleSecureTextinput更改UIImage
@synthesize imageView;
- (IBAction)Stamp:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"SECRET CODE" message:@"Please hand your device to the business representative who will stamp your card" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"STAMP", nil];
alert.alertViewStyle = UIAlertViewStyleSecureTextInput;
[alert show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == alertView.firstOtherButtonIndex)
{
UITextField *textfield = [alertView textFieldAtIndex:0];
NSString *s1 = @"stamp";
if (textfield.text == s1)
{
UIImage * Stampit = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"[email protected]" ofType:@"png"]];
[imageView setImage:Stampit];
}
}
}
使用'testfield.text isEqual:@“stamp”'或'isEqualToString:S1' – 2014-10-03 17:30:15