UIActivityIndicator scrolls with tableView

被刻印的时光 ゝ 提交于 2020-01-25 04:28:07

问题


I have a table view controller .When I start activity indicator to animate and then scroll the table view , activity indicator starts to scroll with that . I have tried to set a specific location for activity indicator and also add it as subview of vew .This is the codes that I have written for that :

spinner.frame.origin.x = self.view.frame.size.width / 2  - (spinner.frame.size.width / 2)
spinner.frame.origin.y = self.view.frame.size.height  - (self.tableView.rowHeight / 2 )
spinner.hidesWhenStopped = true
self.view.addSubview(spinner)

What's wrong with that ?

Thanks in advance


回答1:


When you are using a UITableViewController then self.view is the table (the same as self.tableView). You are adding the spinner to the table so when the table scrolls, the spinner scrolls too.

To avoid this, don't use a UITableViewController. Use a simple UIViewController and add a UITableView to it. Then self.view won't scroll.




回答2:


something like

self.tableView.backgroundView = indicator;

might help



来源:https://stackoverflow.com/questions/29049593/uiactivityindicator-scrolls-with-tableview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!