问题
Greetings!
I've added a UIActivityIndicatorView as a subview of a UITableView. The intent is to fade this view out once the underlying table has been refreshed with new data.
The problem is that the sections in the table view (e.g., A, B, C, etc.) appear to be added after the Activity Indicator appears, partially blocking the activity indicator for a moment.
Is there "a better way" (or more proper way) to be doing this sort of thing when it comes to activity indicators over table views with sections? Right now I'm doing this to fade out the loading
activity indicator view:
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[loading setAlpha:0.0f];
[UIView commitAnimations];
FWIW, calling the equivalent of [myTableView bringSubviewToFront:myActivityIndicatorView]
doesn't appear to help matters either.
On top of that, there's the matter of removing loading
from the superview. I suppose I need to use setAnimationDidStopSelector:
and pass the loading view as context (and maybe I don't really need that CGContextRef line after all).
回答1:
It may well be easier to contain your table in a UIView as a subview, then swap in a loading view as a subview instead until your data is ready for display.
来源:https://stackoverflow.com/questions/1160052/fading-a-uiview-on-top-of-a-uitableview-with-sections