zoukankan      html  css  js  c++  java
  • iOS开发- 自己主动消失的弹出框

    - (void)timerFireMethod:(NSTimer*)theTimer//弹出框
    {
        UIAlertView *promptAlert = (UIAlertView*)[theTimer userInfo];
        [promptAlert dismissWithClickedButtonIndex:0 animated:NO];
        promptAlert =NULL;
    }
    
    
    - (void)showAlert:(NSString *) _message{//时间
        UIAlertView *promptAlert = [[UIAlertView alloc] initWithTitle:@"提示:" message:_message delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
       
        [NSTimer scheduledTimerWithTimeInterval:1.5f
                                         target:self
                                       selector:@selector(timerFireMethod:)
                                       userInfo:promptAlert
                                        repeats:YES];
        [promptAlert show];
    }



    在须要显示弹出框的地方调用[self showAlert:@"測试"];就可以。

    原理: 弹出的时候, 设置一个定时器。 这里设置1.5秒后, 把当前的弹出框置空。  (promptAlert =NULL;)


  • 相关阅读:
    10.28
    10.25
    10.21
    移动第七次作业
    移动第六次作业
    移动第五次作业
    移动第四次作业
    移动第3次作业
    移动第二次作业
    移动第一次作业
  • 原文地址:https://www.cnblogs.com/zhchoutai/p/6769699.html
Copyright © 2011-2022 走看看