ios - Refresh control with UICollectionView reloadData issue -


i continue refining implementation of uicollectionviewcontroller parse , time i'm dealing issue might related cache or maybe reloaddata method itself.

maybe can me identify source of strange behavior better show on short video save time:

refreshing issue video

- (void)viewdidload {     [super viewdidload];     // additional setup after loading view.      refreshcontrol = [[uirefreshcontrol alloc] init];     [refreshcontrol addtarget:self action:@selector(refershcontrolaction) forcontrolevents:uicontroleventvaluechanged];     [self.collectionview addsubview:refreshcontrol];      [self queryfortable];  } 

then on refreshcontrolaction:

- (void)refershcontrolaction {     nslog(@"reload grid");      // user pulled down collection view. start loading data.         [self queryfortable];      [refreshcontrol endrefreshing]; } 

the query method this:

- (void)queryfortable {     pfquery *query = [pfquery querywithclassname:@"photo"];     query.limit = 15;     [query orderbyascending:@"createdat"];     [query setcachepolicy:kpfcachepolicynetworkonly];      [query findobjectsinbackgroundwithblock:^(nsarray *objects, nserror *error) {         if (!error) {             // find succeeded.             nslog(@"successfully retrieved %d photos.", objects.count);              [self.collectionview reloaddata];              gridimages = [[nsmutablearray alloc] initwithcapacity:objects.count];              // found objects             (pfobject *object in objects) {                  pffile *thumbnail = [object objectforkey:@"thumbnail"];                 [thumbnail getdatainbackgroundwithblock:^(nsdata *data, nserror *error) {                     if (!error) {                         // data fetched, update cell's image property thumbnail                          //nslog(@"fetching image..");                          [gridimages addobject:[uiimage imagewithdata:data]];                          //nslog(@"size of gridimages array: %d", [gridimages count]);                      } else {                         // log details of failure                         nslog(@"error: %@ %@", error, [error userinfo]);                     }                 }];             }         } else {             // log details of failure             nslog(@"error: %@ %@", error, [error userinfo]);         }     }]; } 

this doesn't happen on pfquerytableviewcontroller i'm performing exact same query , i'm using ios 6 refresh control instead of 1 provided parse.

do see causing behavior?

i see prob in code.

- (void)refershcontrolaction { nslog(@"reload grid");  // user pulled down collection view. start loading data.     [self queryfortable];  [refreshcontrol endrefreshing]; }  

you endrefreshing before query completed, wrong use. should put [refreshcontrol endrefreshing] in your-(voi)queryfortable` when query complete

the other problem don't know if datasource updated when query completed.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -