【问题标题】:Opening a UIActivityIndicatorView after a UIActionSheet在 UIActionSheet 之后打开 UIActivityIndi​​catorView
【发布时间】:2010-02-08 16:11:52
【问题描述】:

我有一些破坏性操作需要确认,我正在使用 UIActionSheet。

在 clickedButtonAtIndex 中,我触发了一些需要 UIActivityIndi​​catorView 的冗长操作。

问题是在 UIActionSheet 关闭之前我看不到 UIActivityIndi​​catorView,而这发生在操作完成时。

即使用户按下了一些按钮并且他们的 clickedButtonAtIndex 委托已被触发,我也可以强制关闭 UIActionSheet 吗?

在伪代码中:

  • 用户想做一些破坏性的操作
  • 使用 UIActionSheet 请求确认
  • 用户说是
  • 委托 clickedButtonAtIndex 触发并调用冗长的操作
  • 这个操作,做的第一件事是打开一个 UIActivityIndi​​catorView 但是因为 UIActionSheet 是活动的,直到最后我才能看到...

谢谢,

r.

【问题讨论】:

    标签: iphone uiactionsheet uiactivityindicatorview


    【解决方案1】:

    你可以打电话

    CFRunLoopRunInMode(UITrackingRunLoopMode, 0.1, true);
    

    在您开始冗长的计算之前让 UI 元素刷新。或者,您可以使用

    -(void)doLengthyOperation {
       show_activity_indicator_view();
       [self performSelector:@selector(doRealLengthyOperation) withObject:nil afterDelay:0.1];
    }
    -(void)doRealLengthyOperation {
       // do the real lengthy operations.
    }
    

    【讨论】:

    • 这不起作用:CFRunLoopRunInMode(UITrackingRunLoopMode, 0.1, true);我要尝试其他方法...谢谢,r。
    • @mongeta: 可能你需要在kCFRunLoopModeDefault 模式下运行而不是UITrackingRunLoopMode。不过,另一条路线更好。
    • 谢谢,最后两种解决方案的完美结合解决了我的问题。 :-)
    猜你喜欢
    • 1970-01-01
    • 2011-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多