ios - UITableView has extra space on top during "pull down to refresh" -
i have problem tableview. has space on top this:
when open taskstableviewcontroller, problem doesn't show. when open viewcontroller tasktablevc this:
filtertaskstableviewcontroller * fttvc = [self.storyboard instantiateviewcontrollerwithidentifier:@"filtertaskstableviewcontroller"]; fttvc.delegate = self; uinavigationcontroller * navvc = [self.storyboard instantiateviewcontrollerwithidentifier:@"popovernavigationcontroller"]; [navvc setviewcontrollers:@[fttvc]]; [self presentviewcontroller:navvc animated:yes completion:nil];
and go tasktablevc, problem occurs. when "pull down refesh", goes normal.
in code tasktablevc:
- (void)viewwillappear:(bool)animated { //other code [self populate]; } - (void)viewdidload { dispatch_async(dispatch_get_main_queue(), ^{ self.refreshcontrol = [[uirefreshcontrol alloc] init]; self.refreshcontrol.attributedtitle = [[nsattributedstring alloc] initwithstring:@" "]; [self.refreshcontrol addtarget:self action:@selector(refresh) forcontrolevents:uicontroleventvaluechanged]; [self setrefreshcontrol:self.refreshcontrol]; }); [self populate]; } - (void)populate { taskhandler *handler = [[taskhandler alloc] initwithcontext:_context]; nsarray *alltasks = [handler getall]; _tasks = [self filtertasks:alltasks]; nssortdescriptor *descriptor = [[nssortdescriptor alloc] initwithkey:@"startdate" ascending:no]; nsarray *descriptors = [nsarray arraywithobjects:descriptor, nil]; _tasks = [[nsmutablearray alloc] initwitharray:[_tasks sortedarrayusingdescriptors:descriptors]]; dispatch_async(dispatch_get_main_queue(), ^{ [self.tableview reloaddata]; [self.refreshcontrol endrefreshing]; }); }
i hope can me weird problem.
i solved problem code. thought there wrong refresh control
moved out of dispatch_aysnc(dispatch_get_main_queue()
, added [self.tableview reloaddata
. fixed problem. answering. :)
Comments
Post a Comment