简体   繁体   English

表格控制器之间的活动指示器视图-Swift 2

[英]Activity Indicator View between table controllers - swift 2

I have built a project has many tableViewControllers connected together, my project is based on parse so it's taking a long time before it is downloaded and appears. 我已经建立了一个项目,其中有许多tableViewControllers连接在一起,我的项目是基于解析的,因此下载并显示它需要很长时间。

In the main time I want UIActivityIndicatorView to appear as an alert until the tableViewController appears. 通常,我希望UIActivityIndicatorView出现作为警报,直到出现tableViewController为止。 I have found this code: 我找到了以下代码:

var alert: UIAlertView = UIAlertView(title: "Title", message: "Please wait...", delegate: nil, cancelButtonTitle: nil);


    var loadingIndicator: UIActivityIndicatorView = UIActivityIndicatorView(frame: CGRectMake(50, 10, 37, 37)) as UIActivityIndicatorView
    loadingIndicator.center = self.view.center;
    loadingIndicator.hidesWhenStopped = true
    loadingIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
    loadingIndicator.startAnimating();

    alert.setValue(loadingIndicator, forKey: "accessoryView")
    loadingIndicator.startAnimating()

    alert.show();

It's working fine but I have two problems: 工作正常,但我有两个问题:

1 - I can not stop it until click okay -> I want stop and hidden auto after appear data 1-在单击“确定”之前,我无法停止它->在出现数据后我要停止并隐藏自动

2- it is starting and appearing after go in to the tableviewcontroller -> I want start before go 2-它正在启动并进入tableviewcontroller后出现->我想先进入

When it is time for the alert to go away, use this: 当警报消失时,请使用以下命令:

alert.dismissWithClickedButtonIndex(0, animated: true)

Note that UIAlertView is deprecated for iOS 9 请注意,iOS 9不推荐使用UIAlertView

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM