您的位置:首页 > 移动开发 > IOS开发

ios中提示信息的实现及自动消失

2012-06-08 17:35 417 查看
利用UIAlertView+NSTimer可轻松实现这一功能

- (void)timerFireMethod:(NSTimer*)theTimer

{

UIAlertView *promptAlert = (UIAlertView*)[theTimer userInfo];

[promptAlert dismissWithClickedButtonIndex:0 animated:NO];

[promptAlert release];

promptAlert =NULL;

}

- (void)showAlert

{

UIAlertView *promptAlert = [[UIAlertView alloc]
initWithTitle:@"提示:" message:@"添加收藏成功!" delegate:nil
cancelButtonTitle:nil otherButtonTitles:nil];

[NSTimer scheduledTimerWithTimeInterval:0.5f

target:self

selector:@selector(timerFireMethod:)

userInfo:promptAlert

repeats:NO];

[promptAlert show];

}

延迟时间可自己调节。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: