ios - 在 swift 2.0 TableView 中显示事件指示器 3 秒

标签 ios swift uiactivityindicatorview

我将一个自定义 Activity Indicator 放置到我的 TableView 中,并将其命名为:activityIndi​​cator。我也有一个 Action 按钮。当我按下那个按钮时,事件指示器应该显示 3 秒,然后它应该隐藏。如何在 swift 2.0 中做到这一点

@IBAction func RefineButtonPress(sender: AnyObject) {

}

请帮帮我!!

最佳答案

可以尝试这个实现单个函数

@IBAction func RefineButtonPress(sender: AnyObject) {

    self.activityIndicator.startAnimating()
    self.activityIndicator.hidden = false

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (Int64)(3 * NSEC_PER_SEC)), dispatch_get_main_queue()){
         self.activityIndicator.stopAnimating()
         self.activityIndicator.hidden = true

    };
}

关于ios - 在 swift 2.0 TableView 中显示事件指示器 3 秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36256813/

相关文章:

c# - GetViewForHeader 在模拟器中工作但在设备上不工作

ios - 如何链接两个相互连接的 Collection View ?

iphone - 我的事件指标显示在我的算法之后

swift - 如何实现单例微调器(事件指示器)?

swift - 从 Storyboard "This coder requires that replaced objects be returned from initWithCoder"Swift 初始化

ios - 当从 iOS 中的服务获取数据时,如何为指示器设置动画?

ios - 如何使我的 iOS 应用程序安全地与 AWS S3 一起工作

ios - 如何像 iPad 时钟一样制作非常流畅的秒针动画(没有滴答声)

ios - 如何在 View Controller 的多个 View 中添加多种渐变颜色

ios - 如何在 Swift 4.2 xcode 10 中更新 cocoapods