iphone - 如何在tableview底部添加加载更多按钮?

标签 iphone objective-c ios uitableview

我想在 UITableview 的末尾添加一个加载更多按钮。它与 Instagram 中的加载更多按钮具有相同的功能。这是照片。

pic

所以我的问题是如何把它添加到UITableview的末尾?由于 tableview 是可滚动的,我不知道如何给按钮一个动态位置。

提前致谢。

最佳答案

创建一个空的 UIView:UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 70)]; 创建您的按钮:

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"Load More" forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonLoadMoreTouched) forControlEvents:UIControlEventTouchUpInside];
[button sizeToFit];

将按钮添加为 1 中 View 的 subview 。

[v addSubview:button];

将表格的 tableFooterView 属性设置为 1 中的 View 。

self.myTableView.tableFooterView = v;

关于iphone - 如何在tableview底部添加加载更多按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11175634/

相关文章:

iphone - 我什么时候应该使用 UITableViewCell SeparatorStyle Single Line Etched?

iphone - 如何解决线程错误 EXC_BAD_ACCESS?

iOS : 3. 4 : App names in iTunes Connect and as displayed on a device should be similar, 以免造成混淆

ios - Facebook 登录后更改 View Controller

ios - 从 Apple Watch 模拟器与 iPhone 设备通信

iphone - 当 NSAttributedString + NSString 发送到 UIActivityViewController 并选择邮件应用程序时,iOS 7 应用程序崩溃

ios - 核心数据实体重命名

ios - 为什么在模拟器上运行时 mach_wait_until 迟到?

objective-c - NSDictionary 不区分大小写 objectForKey :

ios - 电话后的 PhoneGap 事件