gpt4 book ai didi

ios - UITableView 内容偏移量 -64pt 问题

转载 作者:可可西里 更新时间:2023-11-01 04:38:21 24 4
gpt4 key购买 nike

我正在调试 TableView ,在我的 -viewDidLoad 方法中我有:

<UITableView: 0x7b394600; frame = (0 0; 1024 768); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x7983d2f0>; layer = <CALayer: 0x79836ca0>; contentOffset: {0, 0}>

但是当我在 -viewDidAppear 方法中检查框架和内容偏移时:

<UITableView: 0x7ab79c00; frame = (0 0; 1024 768); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x7998f700>; layer = <CALayer: 0x7998f560>; contentOffset: {0, -64}>

我不知道表的偏移量是如何得到 -64 的。

只有一系列方法 View 确实加载,然后 View 确实出现,但内容偏移对我来说神奇地改变了。

可能是什么原因?

这是我的viewDidLoad:

- (void)viewDidLoad
{
[super viewDidLoad];

_theTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];

_theTableView.dataSource = self;
_theTableView.delegate = self;

[self.view addSubview:_theTableView];

_theTableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];

self.title = @"File Manager";
}

我有导航栏,但奇怪的是我看到了我的表格,因为它应该是没有移动的。所以看起来很完美,我看到了顶部的单元格,当我滚动到底部时,我看到了最后一个单元格。甚至指示器对我说内容偏移量为 0。如果我强制设置内容偏移量 {0, 0} 然后似乎第一个单元格位于导航栏下方并且垂直指示器不是从顶部开始但有一些填充大约 64 pt,但这很奇怪.

我想这是因为状态栏和导航栏。但是如果硬编码创建我的偏移量和框架,它对我没有帮助。好像系统会自动形成我 =)

最佳答案

这是默认行为,查看automaticallyAdjustsScrollViewInsets:

Default value is YES, which allows the view controller to adjust its scroll view insets in response to the screen areas consumed by the status bar, navigation bar, and toolbar or tab bar. Set to NO if you want to manage scroll view inset adjustments yourself, such as when there is more than one scroll view in the view hierarchy.

……以及iOS 7 UI Transition Guide中的其他相关内容.

关于ios - UITableView 内容偏移量 -64pt 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29393335/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com