Fading a UIView on top of a UITableView with Sections

我们两清 提交于 2019-12-10 10:13:08

问题


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

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