【问题标题】:how to make a UIAlertView to hide automatically without User Interaction?如何使 UIAlertView 在没有用户交互的情况下自动隐藏?
【发布时间】:2011-11-28 05:56:27
【问题描述】:

当焦点在屏幕的某个特定区域时,它需要显示一条消息并且需要自动隐藏。 alertview 是否灵活或任何其他方式来实现 iPhone 和 iPad 中的内容。

【问题讨论】:

  • 这里没有人会为你做这件事。展示你的所作所为,你就会得到帮助。

标签: objective-c ipad ios4 xcode4


【解决方案1】:

您可以使用计时器在一段时间后关闭警报,例如:

[[NSTimer scheduledTimerWithTimeInterval:2 
                                 target:self 
                                 selector:@selector(closeAlert:) 
                                 userInfo:nil 
                                 repeats:NO] retain];

更多信息请看这里:NSTimer Class Reference

【讨论】:

    【解决方案2】:

    您可以在显示几秒钟后关闭警报。 像这样的东西:(5秒后关闭)

     UIAlertView *yourAlert = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil]; 
            [yourAlert show];
            [self performSelector:@selector(dismiss:) yourAlert afterDelay:5.0];
    
    
    
    -(void)dismiss:(UIAlertView*)alert
    {
        [alert dismissWithClickedButtonIndex:0 animated:YES];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-08
      • 2014-11-17
      • 1970-01-01
      相关资源
      最近更新 更多