在带有Sections的UITableView顶部使UIView褪色 [英] Fading a UIView on top of a UITableView with Sections

查看:53
本文介绍了在带有Sections的UITableView顶部使UIView褪色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候!

我添加了 UIActivityIndi​​catorView 作为 UITableView 的子视图。目的是在基础表用新数据刷新后淡出该视图。

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.

问题在于表中的 sections 活动指示器出现后,似乎添加了视图(例如A,B,C等),从而部分地阻塞了活动指示器。

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.

一种更好的方式(或更恰当的方式)来处理带有部分的表视图上的活动指示器?现在,我正在这样做,以淡化 loading 活动指示器视图:

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,调用等效于 [myTableView BringSubviewToFront:myActivityIndi​​catorView] 似乎也无济于事。

FWIW, calling the equivalent of [myTableView bringSubviewToFront:myActivityIndicatorView] doesn't appear to help matters either.

最重要的是,删除了加载来自超级视图。我想我需要使用 setAnimationDidStopSelector:并将加载视图作为上下文传递(也许我真的不需要 CGContextRef 行)

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).

推荐答案

将表包含在UIView中作为子视图,然后在加载视图中以直到您的数据可以显示为止。

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.

这篇关于在带有Sections的UITableView顶部使UIView褪色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆