-
- #import <UIKit/UIKit.h>
-
- @interface alertView : UIViewController<UIAlertViewDelegate>
- {
-
- UIAlertView *iToast;
- }
- @property(nonatomic,retain) UIAlertView *iToast;
- -(void) dissmiss:(NSTimer*)timer;
- @end
初始化对象,并添加点击事件
- - (void)viewDidLoad
- {
- [super viewDidLoad];
-
- iToast = [[UIAlertView alloc]initWithTitle:@"警告" message:@"用户名或密码不正确,请重新输入" delegate:self cancelButtonTitle:@"Edit" otherButtonTitles:nil];
-
-
-
-
- [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(dissmiss:) userInfo:nil repeats:YES];
-
- [iToast show];
-
-
- }
-
- - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- {
-
- NSLog(@"buttonIndex = %d",buttonIndex);
- }
-
- -(void) dissmiss:(NSTimer*)timer
- {
-
- [iToast dismissWithClickedButtonIndex:0 animated:NO];
- }
-
- -(void)dealloc
- {
-
- [iToast release];
- [super dealloc];
- }
UIAlertView控件,布布扣,bubuko.com
UIAlertView控件
原文:http://www.cnblogs.com/wlcc/p/3906891.html