【问题标题】:UIActionSheet pass touches through?UIActionSheet 是否通过?
【发布时间】:2013-09-04 00:23:45
【问题描述】:

我希望使用类似于上下文消息框的UIActionSheet(根本没有操作按钮,只是气泡中的一个标签,带有指向某物的箭头)。由于用户无法执行任何操作,我希望它不需要点击即可关闭,但我看不到任何方式(例如 passthroughViews 属性)来允许这样做。

它可能不是为此而设计的,但它确实很方便。

【问题讨论】:

  • 为什么不改用UIPopoverController?创建一个包含内容的简单视图。不要以非预期的方式使用UIActionSheet
  • @rmaddy 主要是因为传递一个字符串并自动调整大小更方便,但是您可能是对的,它确实更有意义。

标签: objective-c ipad cocoa-touch uiactionsheet


【解决方案1】:

这是一些如何显示 UIAlertView 并自动关闭它的示例代码。

显示出来:

- (void)show 
{
     UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"title"
                                               delegate:self
                                      cancelButtonTitle:nil
                                      otherButtonTitles:nil];
     alert.tag = tag;
     [alert show];
}

忽略它:

- (void)dismiss
{
    for (UIWindow* w in [UIApplication sharedApplication].windows)
        for (NSObject* o in w.subviews)
            if ([o isKindOfClass:[UIAlertView class]]) {
                UIAlertView *alert = (UIAlertView*) o;
                if (alert.tag == tag)
                    [alert dismissWithClickedButtonIndex:[(UIAlertView*)o cancelButtonIndex] animated:YES];
            }
}

你可以在几秒钟后调用dismiss方法:

[self performSelector:@selector(dismiss) withObject:nil afterDelay:1.0 inModes:nil];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-23
    • 2011-05-20
    • 1970-01-01
    • 2012-11-19
    • 1970-01-01
    • 1970-01-01
    • 2018-01-13
    • 1970-01-01
    相关资源
    最近更新 更多