iphone - 在 UITableView 的顶部和底部添加按钮

标签 iphone ios objective-c xcode

在我的回合制游戏中,我有一个屏幕显示我目前参加的所有比赛。我为此使用了一个包含 3 个部分的表格 View 。

现在我想在显示的游戏上方添加一个“开始新游戏”按钮。在显示游戏的下方,我想要一些按钮,例如“商店”等。我可以放置它们,但它们不会滚动,所以我需要将它们放在 tableview 中以便它们滚动。

最好的方法是什么?

最佳答案

UIView *headerContainer = [[UIView alloc]initWithFrame:CGRectMake(X, X, X, X)];
UIButton *btnHeader = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[headerContainer addSubview:btnHeader];


UIView *footerContainer = [[UIView alloc]initWithFrame:CGRectMake(X, X, X, X)];
UIButton *btnFooter = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[footerContainer addSubview:btnFooter];


tblView.tableHeaderView = headerContainer;
tblView.tableFooterView = footerContainer;

关于iphone - 在 UITableView 的顶部和底部添加按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14350263/

相关文章:

ios - UILabel 没有立即获取内容

ios - 协议(protocol)功能在 swift 3 中不起作用

ios - 将变量值从文本字段传递到 iOS 中的变量

objective-c - 安装后 Xcode 4.0.2 未启动

ios - 获取 ScrollView 中图像的标签

objective-c - 为什么在多个线程内修改NSMutableSet时崩溃,但是在同一线程内修改自定义对象Person却不会崩溃?

iphone - 尝试使用 ASIFormDataRequest 将图像从 iPhone 上传到服务器

iphone - 使用 SVGKit 加载 SVG 文件

ios - 阻止 super View 识别平移手势(在 iOS 7 中)

iphone - 在消耗品 InAppPurchase 中,在 ios5.1 中找不到但在 ios 6.1 中找到取消交易的委托(delegate)