zoukankan      html  css  js  c++  java
  • 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]; 
    }

    延迟时间可自己调节。

  • 相关阅读:
    java实训
    二维数组转置
    java第四次上机
    建立一个窗体
    java第三次上机
    数据结构晚自习
    Java程序设计第一次作业
    JAVA程序设计的第一次作业
    java中窗体的转化
    数据结构串的使用
  • 原文地址:https://www.cnblogs.com/mazhiyong/p/2542098.html
Copyright © 2011-2022 走看看