我已经创建了一个非常简单的演示应用程序来测试automaticallyAdjustsScrollViewInsets
的功能,但tableView的最后一行被我的标签栏覆盖。
我的AppDelegate代码:
UITabBarController *tabControl = [[UITabBarController alloc] init];
tabControl.tabBar.translucent = YES;
testViewController *test = [[testViewController alloc] init];
[tabControl setViewControllers:@[test]];
[self.window setRootViewController:tabControl];
我的 testViewController(UITableViewController 的子类)代码:
- (void)viewDidLoad
{
[super viewDidLoad];
self.automaticallyAdjustsScrollViewInsets = YES;
self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
self.tableView.dataSource = self;
self.tableView.scrollIndicatorInsets = self.tableView.contentInset;
//[self.view addSubview:self.tableView];
// Do any additional setup after loading the view.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 20;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@""];
cell.textLabel.text = @"test";
return cell;
}
这是iOS 7的一个bug吗?如果不是,那我做错了什么?
automaticallyAdjustsScrollViewInsets
在iOS 11中已被弃用。苹果公司表示:“请使用UIScrollView的contentInsetAdjustmentBehavior代替”。 - PDK