本文主要是介绍UI05_UIAlertView,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
AppDelegate.m
#import "AppDelegate.h"1.使用UIAlertViewDelegate需要签订协议.
@interface AppDelegate ()<UIAlertViewDelegate>@end
@implementation AppDelegate// 在ARC可以写dealloc(在观察者中使用),但是里面不写内容.
- (void)dealloc
{[_window release];[super dealloc];
}- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];// Override point for customization after application launch.self.window.backgroundColor = [UIColor whiteColor];[self.window makeKeyAndVisible];[_window release];2.创建UIAlertViewUIAlertView *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);
}
这篇关于UI05_UIAlertView的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!