【发布时间】:2016-04-30 07:09:18
【问题描述】:
我正在 Swift 中构建一个显示 UITableView 单元列表的应用程序。当用户点击一个单元格时,我希望按顺序执行以下操作:
- 取消选择索引路径处的行
- 显示 UIActivitySpinner 并为其设置动画
- 执行一项功能(大约持续 10 秒)
- 隐藏 UIActivitySpinner
我目前的代码如下:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
self.tableView.deselectRowAtIndexPath(indexPath, animated: true)
let cell = tableView.cellForRowAtIndexPath(indexPath) as! TableViewCell
cell.ActivitySpinner.startAnimating()
myFunction() // Approximately 10 seconds.
cell.ActivitySpinner.stopAnimating()
return
}
所以这个想法是 UIActivitySpinner 将在 myFunction() 执行时出现 10 秒,并在 myFunction() 完成时消失。
当前的问题是 UIActivitySpinner 仅在 myFunction() 完成执行后出现。我不确定如何让 ActivitySpinner 在 myFunction() 开始之前出现,并在 myFunction() 完成后消失。
关于 myFunction():它是一个 C 函数,链接在桥接头中,主要是 HTTP 请求。
【问题讨论】:
标签: swift uitableview