Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableview not reloading
    primarykey
    data
    text
    <p>I have a <code>tableview</code> loading properly for the first time, but it should reload the data when I'm calling the method <code>loadJsonData</code>. The <code>reloadData</code> method is called at the end of the <code>loadJsonData</code> method. But the <code>tableview</code> is not reloading. The data source is updated before calling the <code>reloadData</code> method. The delegate and dataSource of <code>tableview</code> are also set to self.</p> <p>I checked if it is executing <code>numberOfRowsInSection</code> method and found that it is not executing the method. Can anybody help me?</p> <p>Below is the code:</p> <pre><code>-(void)loadJsonData:(NSString *)fileName:(int )count { titleArray=[[NSMutableArray alloc]init]; dateArray=[[NSMutableArray alloc]init]; descriptionArray=[[NSMutableArray alloc]init]; urlArray=[[NSMutableArray alloc]init]; thumbnailArray=[[NSMutableArray alloc]init]; NSString *filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"json"]; NSString *fileContent = [[NSString alloc] initWithContentsOfFile:filePath]; SBJSON *Parser = [[SBJSON alloc] init]; NSDictionary *data = (NSDictionary *) [Parser objectWithString:fileContent error:nil]; NSArray *items=[data objectForKey:fileName]; NSSortDescriptor *sortDescriptor; sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"date" ascending:YES] autorelease]; NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor]; NSArray *sortedArray; sortedArray = [items sortedArrayUsingDescriptors:sortDescriptors]; items=sortedArray; for (NSDictionary *item in items) { NSString *temp=[item objectForKey:@"title"]; NSString* str = [temp stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [titleArray addObject:str]; temp=[item objectForKey:@"date"]; [dateArray addObject:temp]; temp=[item objectForKey:@"thumbnailURL"]; str = [temp stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [thumbnailArray addObject:str]; temp=[item objectForKey:@"description"]; str = [temp stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [descriptionArray addObject:str]; temp=[item objectForKey:@"htmlURL"]; str = [temp stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [urlArray addObject:str]; } [Parser release]; if (count==1) { [tableview performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO]; NSLog(@"reload data test"); } } -(NSInteger) numberOfSectionsInTableView:(UITableView *)aTableView { // Return the number of sections. return 1; } -(NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. NSLog(@"nof rows test.."); return [thumbnailArray count]; } </code></pre> <p>EDIT</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { CustomCell *cell; cell=(CustomCell *)[tableView dequeueReusableCellWithIdentifier:@"cell"]; if (cell == nil) { cell = [[[CustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"cell"] autorelease]; cell.contentMode=UIViewContentModeScaleAspectFit; cell.Title.text=[titleArray objectAtIndex:indexPath.row]; cell.description.text=[descriptionArray objectAtIndex:indexPath.row]; NSURL *url = [NSURL URLWithString:[thumbnailArray objectAtIndex:indexPath.row]]; NSData *data = [NSData dataWithContentsOfURL:url]; UIImage *img = [[UIImage alloc] initWithData:data]; cell.Image.image=img; cell.Date.text=[dateArray objectAtIndex:indexPath.row]; NSLog(@"date is : %@",cell.Date.text); cell.selectionStyle=UITableViewCellSelectionStyleNone; } return cell; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload