Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UIView未显示在UITableView的顶部_Iphone_Ios_Objective C_Uitableview_Uiview - Fatal编程技术网

Iphone UIView未显示在UITableView的顶部

Iphone UIView未显示在UITableView的顶部,iphone,ios,objective-c,uitableview,uiview,Iphone,Ios,Objective C,Uitableview,Uiview,我有一个UIViewController,上面有一个UITableView。我试图在表视图的顶部放置一个小的UIView覆盖。我以编程的方式添加了它(并使用了将subviewtofront),然后在Interface Builder中添加了它,但这两种方式都没有出现 为什么呢?如何在表视图顶部添加ui视图覆盖 编辑: 我没有使用UITableViewController。它是一个UIViewController,带有UITableView。下面是我在viewDidLoad中使用的代码: UIVi

我有一个
UIViewController
,上面有一个
UITableView
。我试图在表视图的顶部放置一个小的
UIView
覆盖。我以编程的方式添加了它(并使用了
将subviewtofront
),然后在Interface Builder中添加了它,但这两种方式都没有出现

为什么呢?如何在表视图顶部添加
ui视图
覆盖

编辑:

我没有使用
UITableViewController
。它是一个
UIViewController
,带有
UITableView
。下面是我在
viewDidLoad
中使用的代码:

UIView *joinMediame = [[UIView alloc] initWithFrame:CGRectMake(0, 44, 320, 44)];
joinMediame.backgroundColor = [UIColor orangeColor];
[self.view addSubview:joinMediame];
[self.view bringSubviewToFront:joinMediame];

如果您希望视图与表格内容一起滚动,我会将其设置为表格的
tableHeaderView
。如果希望视图在顶部是静态的,我会将其添加为控制器的子视图,然后调整表视图框架的大小,为静态视图腾出空间


请注意,如果控制器是一个
UITableViewController
self.view
是一个
UITableView
,那么如果您执行类似于
[self.view addSubview:staticView]
的操作,这将不会产生预期的效果。

您可以发布用于添加视图的代码吗,请问?您是否使用TableView作为viewController的根视图?如果是,请将根视图更改为普通UIView,并将表添加为子视图,将覆盖添加为表的同级。如果不是UITableViewController,则使用
addSubview
应该可以正常工作。请发布您的代码。请参见edit Please@Verbumdei和tableView?它是在nib文件中还是通过代码添加的?我希望它是静态的。我将其添加为子视图(请参见编辑),但它不会静止显示。您是否也调整了表的框架?不,我没有。我需要吗?将子视图置于顶部还不够吗?在Interface Builder中,当我调整表视图的大小使其变短时,它在iPhone上实际上并没有变短。怎么可能?你也调整了自动调整大小的遮罩了吗?