Skip to content

Instantly share code, notes, and snippets.

@sinri
Created February 9, 2015 05:50
Show Gist options
  • Save sinri/6677ad1c0af72693eb66 to your computer and use it in GitHub Desktop.
Save sinri/6677ad1c0af72693eb66 to your computer and use it in GitHub Desktop.
Block化進化したUIAlertView ref: http://qiita.com/sinri/items/17f565680f7026de49b8
SinriAlertView * sav=[[SinriAlertView alloc]initWithTitle:NSLocalizedString(@"_CashingCoupon_InputBox_Title", @"Cashing Coupon")
message:NSLocalizedString(@"_CashingCoupon_InputBox_Message", @"Input your coupon code to cashing.")
cancelButtonTitle:NSLocalizedString(@"Cancel", @"Cancel")
otherButtonTitles:NSLocalizedString(@"Confirm", @"Confirm"),nil];
[sav setClickHandler:^(UIAlertView *sinriAlertView, NSInteger buttonIndex) {
NSLog(@"SinriAlertView ボタン index=%ld",buttonIndex);
if (buttonIndex == 1) {
UITextField *tf=[sinriAlertView textFieldAtIndex:0];
NSString* cashCode = tf.text;
NSLog(@"SinriAlertView コード:%@",cashCode);
}
}];
sav.alertViewStyle = UIAlertViewStylePlainTextInput;
[[sav textFieldAtIndex:0] setKeyboardType:UIKeyboardTypeNumberPad];
[[sav textFieldAtIndex:0] becomeFirstResponder];
[sav show];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment