ios - 如何修复表格 View 底部的按钮?
<p><p>在我的应用程序中,我想在表格 View 底部修复一个按钮。</p>
<p>这是我的初始屏幕,</p>
<p> <a href="/image/XwuUS.png" rel="noreferrer noopener nofollow"><img src="/image/XwuUS.png" alt="enter image description here"/></a> </p>
<p>在页 footer 分创建的按钮</p>
<pre><code>-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
if(tableView == educateTbl)
{
float footerWidth = 150.0f;
float padding = 10.0f;
UIView *footerView = [initWithFrame:CGRectMake(0, 0, footerWidth, 50.0)];
footerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
UIButton *addEdu = [initWithFrame:CGRectMake(padding, 0, footerWidth - 2.0f * padding, 44.0f)];
addEdu.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
addEdu.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
;
;
forState:UIControlStateNormal];
addEdu.frame=CGRectMake(0, 0, 200, 30);
;
return footerView;
}
return nil;
}
</code></pre>
<p>后来我就这样了,</p>
<p> <a href="/image/q2YsG.png" rel="noreferrer noopener nofollow"><img src="/image/q2YsG.png" alt="enter image description here"/></a> </p>
<p>我该如何解决这个问题?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>你为什么不做这样的东西?</p>
<pre><code>-(void)setTableFooter
{
float footerWidth = 150.0f;
float padding = 10.0f;
UIView *footerView = [initWithFrame:CGRectMake(0, 0, footerWidth, 50.0)];
footerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
UIButton *addEdu = [initWithFrame:CGRectMake(padding, 0, footerWidth - 2.0f * padding, 44.0f)];
addEdu.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
addEdu.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
;
;
forState:UIControlStateNormal];
addEdu.frame=CGRectMake(0, 0, 200, 30);
;
tableView.tableFooterView = footerView;
}
</code></pre>
<p>在你初始化表格后调用它</p></p>
<p style="font-size: 20px;">关于ios - 如何修复表格 View 底部的按钮?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/36769002/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/36769002/
</a>
</p>
页:
[1]