打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

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


利用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]; 
}

延迟时间可自己调节。

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
在新线程中使用NSTimer
UIAlertView自动消失
NSTimer知识点和倒计时的实现
iOS开发 录音以及播放 AVAudioRecorder
NSTimer类的使用
NSTimer和实现弱引用的timer的方式
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服