【发布时间】:2012-12-01 20:05:19
【问题描述】:
如何修复屏幕上的子视图位置(尤其是在 UIScrollView 和 UITableView 中)?我认为在故事板中
[self.view addSubview:aSubView];
不再起作用了。
有什么想法吗?
编辑#1:我使用的是 UITableViewController,而不是简单的 UITableView。
编辑#2:
CGRect fixedFrame = self.menuViewRelative.frame;
fixedFrame.origin.y = 0 + scrollView.contentOffset.y;
self.menuViewRelative.frame = fixedFrame;
menuViewRelative = [[UIView alloc] init];
menuViewRelative.backgroundColor = [UIColor grayColor];
menuViewRelative.frame = CGRectMake(0.0, 0.0, 320.0, 50.0);
[self.view addSubview:self.menuViewRelative];
【问题讨论】:
-
请充实你的问题......我不明白你想要做什么。
-
在 ios 6 中你可以在 xib 中使用约束
-
我想修复子视图 (UIView) 的位置,这样它就不会随着 UITableView 的内容滚动。子视图应该固定在屏幕上..
-
您将不应滚动的视图添加为滚动视图的同级。假设您的滚动视图或表格视图是视图/窗口
XY的子视图,只需将您的固定视图也添加为 XY 的子视图。 -
@Till:对不起,我忘了说这是一个 UITableViewController :S 对不起。有什么想法吗?