如何防止tableview与工具栏发生冲突?

时间:2016-02-15 07:35:41

标签: ios objective-c user-interface uitoolbar

我有一个工具栏,我使用Storyboard静态添加。动态地我添加了应该出现在工具栏下方的子视图(这是一个tableview)。 当我尝试这样做时,tableview与工具栏发生冲突。

我的代码如下,

 UITableView *tableView=[[UITableView alloc]init];
tableView.estimatedRowHeight = 44.0 ;
tableView.rowHeight = UITableViewAutomaticDimension;
tableView.frame = CGRectMake(10,30,320,400);
[tableView setNeedsUpdateConstraints];
tableView.dataSource=self;
tableView.delegate=self;
tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
[tableView reloadData];
tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
[tableView sizeToFit];

[self.view addSubview:tableView];

这是截图 enter image description here

1 个答案:

答案 0 :(得分:-1)

你可以在tableView和toolBar之间添加一个约束,比如把距离设置为0吗?

相关问题