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

http://blog.csdn.net/horse20000/article/details/7542881

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

延迟时间可自己调节。

posted @ 2013-01-25 10:44  六界剑仙  阅读(157)  评论(0)    收藏  举报