开发者

How to reuse the same UIView among different tabs?

In a tab bar application with a UIWebView for each tab, I want to show a loading screen that is displayed in webViewDidStartLoad and then gets hidden in webViewDidFinishLoad. Right now I have a UIView in every nib file, but I开发者_开发技巧 was wondering what could be a better way to reuse just one UIView.

Thanks!


It's one possibility.

If you want to do that you have to play with the window and why not your application delegate.

Just add a loading view as an application delegate attribute. And then create two functions in the appDelegate

-(void)startLoading
{
[self.loadingView removeFromSuperview];
}

and

-(void)stopLoading
{
[[UIApplication sharedApplication].keyWindow addSubview:self.loadingView];
}

And that's it ! Just invoke the methods when you needs them.

E.G :

[((AppDelegateClassName *)[UIApplication sharedApplication].delegate) startLoading];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜