注意:cancelButton的index == 0
- (void)PWtypeClicked:(UIButton *)btn {
NSLog(@"点击选择类型密码按钮");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"选择密码类型" message:nil delegate:self cancelButtonTitle:@"一级密码" otherButtonTitles:@"二级密码", nil];
[alert show];
}
pragma mark -- alertDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
UITextField *tmpField = (UITextField *)[self.view viewWithTag:100];
if (buttonIndex == 0) {
tmpField.text = @"一级密码";
} else if(buttonIndex == 1){
tmpField.text = @"二级密码";
}
}