UIAlertController * alert = [UIAlertControlleralertControllerWithTitle:@""message:@""preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *firstAction = [UIAlertActionactionWithTitle:@"确定"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *action) {
flag =1;
[selfplatAlertWithFlag:flag];
//do something
}];
UIAlertAction *secondAction = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *action) {
//do something
flag =2;
[selfplatAlertWithFlag:flag];
}];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder =@"请输入购买数量";
[[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(alertTextFieldDidChange:)name:UITextFieldTextDidChangeNotificationobject:textField];
textField.tag=123;
textField.keyboardType =UIKeyboardTypeNumberPad;
NSLog(@"textField:%@",textField.text);
// textField.keyboardType = UIKeyboardTypeNumberPad;
}];
-(void)alertTextFieldDidChange:(NSNotification *)obj
{
UITextField *textField = (UITextField *)obj.object;
if (textField.tag==123) {
count = [textField.textintegerValue];
}
elseif(textField.tag ==456)
{
_size = textField.text;
}
else
{
self.model.ordSpeci = textField.text;
self.proSize = textField.text;
NSLog(@"self.model.ordSpeci:%@",self.model.ordSpeci);
}
}