IOS 7.0调用Alert view 添加textfield

来源:互联网 发布:c语言 bmp 像素值读取 编辑:程序博客网 时间:2024/04/28 11:39

自己记录


UIAlertView *barcodeAlert = [[UIAlertViewalloc]initWithTitle:NSLocalizedString(@"提貨碼",@"提貨碼") message:NSLocalizedString(@"請輸入你的提貨碼:\n\n",@"請輸入你的提貨碼:\n\n") delegate:self cancelButtonTitle:NSLocalizedString(@"取消",@"取消")otherButtonTitles:NSLocalizedString(@"確定",@"確定"),nil];

        

        barcodeAlert.alertViewStyle =UIAlertViewStylePlainTextInput;//最主要的是这个

        //补充

  

       UITextField * barcodeTextField=[barcodeAlerttextFieldAtIndex:0];//获得对应的文本框,

       barcodeTextField.keyboardType=UIKeyboardTypeNumberPad;//设置数值类型



获取值


- (void) alertView:(UIAlertView *) alertView clickedButtonAtIndex:(NSInteger) buttonIndex {

    

   

UITextField *barcodeTextField=[alertViewtextFieldAtIndex:0];

   NSLog(@"textval:%@",barcodeTextField.text);

}
0 0
原创粉丝点击