---
title: "ios alertView添加输入框"
author: "chenjohney"
date: "2011-12-14T14:46:52Z"
tags: []
categories: ["移动开发"]
slug: "ios-alertview"
draft: false
lastmod: "2012-09-25T14:50:51Z"
id: 1310341
url: "https://chenjohney.iteye.com/blog/1310341"
---

初始化UIAlertView后

 设置 alertView 的alertViewStyle

UIAlertViewStylePlainTextInput 添加一个普通输入框

UIAlertViewStyleSecureTextInput 密码输入框

UIAlertViewStyleLoginAndPasswordInput 普通输入框加密码输入框

加一句

\[alert addTextFieldWithValue:@"" label:@""]; 注:这个方法已经被列为私有API,不可用了

\[alert show];

 

 

然后在

```
-（void）alertView : (UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{

       //得到输入框

           UITextField *tf=[alertView textFieldAtIndex:0];

         

         [alertView release];

}

 
```