我在swift中做了一个iOS 8自定义键盘,我在视图中添加了一个UIActivityIndicatorView,问题是我可以看到它,但是没有旋转,它是静态的,这是代码:
@IBOutlet var menuLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
self.load_indicator = UIActivityIndicatorView(frame: CGRectMake(0,0, 50, 50)) as UIActivityIndicatorView
self.load_indicator.hidesWhenStopped = true
self.load_indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
self.view.addSubview(self.load_indicator)
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
dispatch_async(dispatch_get_main_queue(), {
self.load_indicator.startAnimating()
})
}
出现加载指示,但它是静态的,我该怎么做?
答案 0 :(得分:0)
load_indicator = UIActivityIndicatorView(frame: CGRectMake(0,0, 50, 50))
load_indicator.hidesWhenStopped = true
load_indicator.startAnimating()
load_indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
view.addSubview(load_indicator)
你需要用
开始动画load_indicator.startAnimating()