问题
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