添加的UIView背后的UITableView中的UITableViewController code [英] Add UIView behind UITableView in UITableViewController code

查看:142
本文介绍了添加的UIView背后的UITableView中的UITableViewController code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用一个固定的形象,在我的iPhone程序简单的分组表视图的背景。不幸的是,无论我做什么,背景永远是白色固体。我按照在本网站和其他人都没有用几个假想的解决方案。这里是表视图控制器类的viewDidLoad方法(注意,这code采用了坚固的蓝色,而不是图像为了简单起见)的初步认识code:

I would like to use a fixed image as the background in a simple grouped table view in my iPhone program. Unfortunately, no matter what I do, the background is always solid white. I have followed several supposed solutions on this site and others to no avail. Here is the relavant code in the viewDidLoad method of the table view controller class (note, this code uses a solid blue color rather than an image for simplicity's sake):

self.tableView.opaque = NO;
self.tableView.backgroundColor = [UIColor clearColor];
UIView *backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
backgroundView.backgroundColor = [UIColor blueColor];
[self.tableView.window addSubview:backgroundView];
[backgroundView release];

我怀疑我不是定位在正确的地方的backgroundView视图。我曾尝试sendToBack :, bringToFront:和其他人,但我始终只是得到一个白色背景。是否有可能从内部的UITableViewController做到这一点?我必须使用Interface Builder?

I suspect that I am not positioning the backgroundView view in the right place. I have tried sendToBack:, bringToFront:, and others but I always just get a white background. Is it possible to do this from within the UITableViewController? Must I use Interface Builder?

推荐答案

使用的的UITableView 子视图属性添加你的背景有:

Use UITableView's subviews property to add your background there:

[self.tableView addSubview:backgroundView];
[self.tableView sendSubviewToBack:backgroundView];

另外,你的细胞/报头等等将可能需要被设置为透明的,你的backgroundView可见。

Also, your cell/header etc. will probably need to be set to transparent for your backgroundView to be visible.

这篇关于添加的UIView背后的UITableView中的UITableViewController code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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