在我的应用程序中,我想在表格 View 底部修复一个按钮。
这是我的初始屏幕,
在页 footer 分创建的按钮
-(UIView *)tableViewUITableView *)tableView viewForFooterInSectionNSInteger)section
{
if(tableView == educateTbl)
{
float footerWidth = 150.0f;
float padding = 10.0f;
UIView *footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, footerWidth, 50.0)];
footerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
UIButton *addEdu = [[UIButton alloc]initWithFrame:CGRectMake(padding, 0, footerWidth - 2.0f * padding, 44.0f)];
addEdu.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
addEdu.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[addEdu setTitle"Add Education" forState:UIControlStateNormal];
[addEdu addTarget:self actionselector(addEducation forControlEvents:UIControlEventTouchUpInside];
[addEdu setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
addEdu.frame=CGRectMake(0, 0, 200, 30);
[footerView addSubview:addEdu];
return footerView;
}
return nil;
}
后来我就这样了,
我该如何解决这个问题?
你为什么不做这样的东西?
-(void)setTableFooter
{
float footerWidth = 150.0f;
float padding = 10.0f;
UIView *footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, footerWidth, 50.0)];
footerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
UIButton *addEdu = [[UIButton alloc]initWithFrame:CGRectMake(padding, 0, footerWidth - 2.0f * padding, 44.0f)];
addEdu.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
addEdu.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[addEdu setTitle"Add Education" forState:UIControlStateNormal];
[addEdu addTarget:self actionselector(addEducation forControlEvents:UIControlEventTouchUpInside];
[addEdu setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
addEdu.frame=CGRectMake(0, 0, 200, 30);
[footerView addSubview:addEdu];
tableView.tableFooterView = footerView;
}
在你初始化表格后调用它
关于ios - 如何修复表格 View 底部的按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36769002/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |