1

我有一个表格视图设置,当前,当它闪烁时,它的部分与状态栏正下方齐平,而不是与导航栏齐平。我不确定这是否是正确的行为,但是当它滑入视图时,大多数应用程序都会在导航栏下方正确刷新部分标题。

纠正这个问题而不是任意缩小 tableView 的正确方法是什么?

* 编辑 *

与我在Broken cell 中创建的带有奇怪删除线的线程有关?. 当我将导航栏设置为半透明黑色时,会出现此问题以及“单元格删除线”问题。当它是黑色不透明或正常时,不存在这样的问题。我不确定这是因为我的代码中的其他内容还是 SDK 的问题。

4

4 回答 4

3

听起来您要么没有在 IB 中正确设置边界,要么您的弹簧和支柱不正确。这是 UIViewController 的顶层,还是子视图?你在使用 UINavigationController 吗?如果在 IB 中测试接口,看起来还可以吗?

于 2008-11-26T18:01:00.417 回答
1

我遇到了类似的问题,通过设置它会自动修复

self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
于 2011-04-13T04:45:48.283 回答
0

正如我在另一篇文章中指出的那样,我怀疑 UINavigationController 下的视图层次结构已被破坏。

UINavigationController 的内容视图(包含导航栏和您的 UITableView)中的 layoutSubviews 应该调整 UITableView 的大小,使其不与导航栏重叠。在您的情况下,我猜测 UITableView 之后会自行调整大小,或者 layoutSubviews 出于某种原因不知道 UITableView 并且 UITableView 在导航栏下方传递,从而导致您看到的对齐问题。

于 2008-11-26T23:40:58.717 回答
0

我在 iOS 5.1 上使用以下代码遇到了同样的问题:

创建导航控制器并添加表格视图

UINavigationController *navigationController = [[UINavigationController alloc] init];
[navigationController setModalPresentationStyle:UIModalPresentationFormSheet];
[navigationController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[navigationController.navigationBar setBarStyle:UIBarStyleBlack];
[navigationController.navigationBar setTranslucent:TRUE];
[navigationController setNavigationBarHidden:NO animated:NO];
[self presentModalViewController:navigationController animated:YES];

MyTableViewController *aTableViewController = [[[MyTableViewController alloc] initWithStyle:UITableViewStylePlain] autorelease];
aTableViewController.navigationItem.rightBarButtonItem = buttonItem;
[navigationController pushViewController:aboutTableViewController animated:YES];

将表头视图添加到表中

ATableHeaderView aTableHeaderView = [[[ATableHeaderView alloc] initWithFrame:aboutTableView.frame] autorelease]; 
[aTableHeaderView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin];
[aTableHeaderView sizeToFit];
[aTableView setTableHeaderView:aTableHeaderView];

在表头视图中,我添加了一些标签

UILabel *aLabel = [[[UILabel alloc] initWithFrame:CGRectMake(x,y, width, height)] autorelease];
[aLabel setText:aString];
[aLabel setAutoresizesSubviews:YES];
[aLabel setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];

我最终得到了导航栏下的表格标题内容。将导航栏更改为纯黑色修复了它。但这不是我想要的。经过反复试验,我删除了该行:

[aLabel setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];

从标题中 UILabel 的设置,问题得到解决。我有一个半透明的标题,表格的内容定位正确。

于 2012-07-26T09:21:05.060 回答