我可以在界面生成器中将表格视图添加到现有视图吗?
我的接口构建器如下所示
但是当我在模拟器中运行代码时,您可以看到该表没有显示在与界面生成器中相同的位置,因为它覆盖了底部的按钮???
更新...我有点进步,但底部的按钮被隐藏了??
已修复...按照建议使用以下代码:)
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 40)];
view.backgroundColor = [UIColor whiteColor];
UIButton *buttonA = [UIButton buttonWithType:UIButtonTypeRoundedRect];
buttonA.frame = CGRectMake(101,5,118,29);
[buttonA setTitle:@"Save & Exit" forState:UIControlStateNormal];
buttonA.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[view addSubview:buttonA];
UIButton *buttonB = [UIButton buttonWithType:UIButtonTypeRoundedRect];
buttonB.frame = CGRectMake(254,5,56,29);
[buttonB setTitle:@"Next" forState:UIControlStateNormal];
buttonB.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[view addSubview:buttonB];
return view;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 40;
}