我正在使用pull来刷新tableview上的常规数据刷新。
这是我的代码
-(void)addUIRefreshControl{
//Instantiate and Configure Refresh Control
self.refreshControl = [[UIRefreshControl alloc] init]; // initialize refresh control
self.refreshControl.tintColor = [UIColor appBaseColor]; // set tint color
[self.refreshControl addTarget:self
action:@selector(refreshAPI)
forControlEvents:UIControlEventValueChanged]; // add target
[self.tableView addSubview:self.refreshControl]; // add the refresh control
}
-(void)refreshAPI{
if ([APP_DELEGATE isNetAvailable]) {
[self fetchAPI];
}else{
if (self.refreshControl) {
[self.refreshControl endRefreshing]; //end refreshing
}
}
}
iOS设备上的一切正常模拟器除了iPhone X.任何人都可以建议我做错了什么?
由于
答案 0 :(得分:0)
你的应用是iOS 10&只有更新?如果是这样,您应该使用注释掉的行:
- (void)addUIRefreshControl{
UIRefreshControl * refreshControl = [[UIRefreshControl alloc] init]; // initialize refresh control
refreshControl.tintColor = [UIColor appBaseColor]; // set tint color
refreshControl addTarget:self
action:@selector(refreshAPI)
forControlEvents:UIControlEventValueChanged]; // add target
if (self.tableView != NULL) {
// tableView will have a strong reference (and retain) refreshControl ; no need to have it be its own property
self.tableView.refreshControl = refreshControl
} else {
NSLog(@"suprise! self.tableView is null");
}
}
当值更改(或更新)时,您应始终调用“endRefreshing”。以前,只有当isNetAvailable
为假时才会打电话。
-(void)refreshAPI{
if ([APP_DELEGATE isNetAvailable]) {
[self fetchAPI];
}
[self.tableView.refreshControl endRefreshing]; //end refreshing
}