AppDelegate.m
#import "AppDelegate.h"
1.使用UIAlertViewDelegate需要签订协议.
@interface AppDelegate ()<UIAlertViewDelegate>
@end
@implementation AppDelegate
- (void)dealloc
{
[_window release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
[_window release];
2.创建UIAlertView
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"1" message:@“2” delegate:self cancelButtonTitle:@"3" otherButtonTitles:@"4", nil];
3.在提示框上出现输入框,可以设置输入框的样式.
alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
[alert show];
return YES;
}
4.监控UIAlertView中的button.
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"%ld”, buttonIndex);
}