我的演示代碼很簡單:我希望在視圖控制器是目前從網絡加載,所以我必須從viewDidLoad中手動調用beginRefreshing顯示加載refreshControl在開始uirefreshcontrol不顯示時的tableview有許多行
#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
@Leo OK,我已經發布了代碼:) – ximmyxiao