开发者

Why can't I place a UIActivityIndicatorView on a UITableView by using Interface Builder?

I can place a UIActivityIndicatorView on a UIWindow or a UIView by using Interface Builder like as follows.

Why can't I place a UIActivityIndicatorView on a UITableView by using Interface Builder?

(source: hatena.ne.jp)

But I can't place a UIActivityIndicatorView on a UITableView by using Interface Builder.

What开发者_StackOverflow社区's the reason? Are there any ways?

I can place it on a UITableView programmatically.

Why can't I place a UIActivityIndicatorView on a UITableView by using Interface Builder?

(source: hatena.ne.jp)


Make the UITableView and the UIActivityIndicatorView both subviews of a parent UIView. You can then place the indicator view atop the table view.


The reason is because UITableView expects to be in charge of all of every one of its subviews for layout purposes. IB doesn't let you put subviews in a UITableView because while it is technically possible it is not supported.

In any case, the activity indicator would scroll up and down with the table, so even if you add it at the right place if the table is scrolled down, you could scroll it off the screen if you're not careful about deactivating user interaction while the indicator is showing.

When I need to show a generic activity indicator on the screen over everything, I use my own version of the UIProgressHUD. The UIProgressHUD is a private internal class, so I don't use that, I just made my own that does the same thing. It makes a view with a black background at 50% opacity and rounded corners, and I add a progress indicator and optionally a label to it, then I just add that view to the main window. Thus, no need for another UIView to encapsulate both, and you're not putting it in the table, which isn't supported (unless you put it within a cell within the table view).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜