iPhone控件之UIAlertView

复制代码
#import "UITestViewController.h"

NSTimer *timer;

@implementation UITestViewController

- (void)hideAlert:(NSTimer *)sender
{
UIAlertView *alert = [sender userInfo];

[alert dismissWithClickedButtonIndex:0 animated:YES];
}

- (void)viewDidLoad {

[super viewDidLoad];

UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"title"
message:@"This alert will disappear in 3 seconds"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];

[myAlert addButtonWithTitle:@"new button"];
[myAlert addButtonWithTitle:@"another button"];

[myAlert show];

//create a timer to hide the alert automatically in 3 seconds
timer = [[NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(hideAlert:) userInfo:myAlert repeats:NO] retain];

[myAlert release];
}
复制代码
posted @   FoxBabe  阅读(252)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示