【问题标题】:iOS, alert with no button to dismiss?iOS,没有关闭按钮的警报?
【发布时间】:2012-06-29 20:20:17
【问题描述】:

我想显示一个没有按钮的警报窗口,这意味着用户不能自己关闭它,只有我的代码可以关闭警报。如何实现?

【问题讨论】:

  • 你真的不应该这样做!
  • @hypercrypt 请告诉我们为什么我们不能这样做。我还在我的一个应用程序中使用了这种类型的警报。一段时间后我将关闭警报。
  • 我同意,从用户体验的角度来看,这似乎是糟糕的设计。
  • 我可以这样做,但你不应该这样做。正如 Da_smokes 所说,这不是一个好的用户体验。

标签: iphone ios


【解决方案1】:
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Hello World!"
                                                  message:@"This is sample message."
                                                 delegate:self
                                        cancelButtonTitle:nil
                                        otherButtonTitles:nil];
message.tag = 123;
[message show];
[message release]

使用它来制作没有按钮的警报

要关闭警报视图,请使用类似于此的一些逻辑

UIAlertView *alert = (UIAlertView)[[self.view viewWithTag:123]
[alert dismissWithClickedButtonIndex:0 animated:TRUE];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-11
    • 1970-01-01
    • 2020-06-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多