【发布时间】:2016-03-08 07:10:12
【问题描述】:
我的演示代码非常简单:我想在视图控制器存在时从网络加载,所以我必须从 viewdidload 手动调用 beginRefreshing 以显示开始时的加载 refreshControl
#import "ViewController.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UITableView *tableView;
@property(nonatomic,strong) UIRefreshControl* control;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];
self.control = [UIRefreshControl new];
[self.tableView addSubview:self.control];
[self.tableView reloadData];
[self.control beginRefreshing];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 3;
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell* cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.backgroundColor = [UIColor redColor];
return cell;
}
@end
但如果我将节数更改为更大的数字,例如 10(总行数为 30),刷新控件将不会显示
这是系统错误吗?还是我使用刷新控制的方式不对?
【问题讨论】:
-
请发布代码而不是代码截图。
-
@Leo 好的,我已经把代码贴出来了:)
标签: ios uitableview uirefreshcontrol