I am trying to update my UITableview, but when I call [tableView reloadData];, the table update is not updated after I scroll the table view over the cell name when changing. But this is not adding a new line or anything like that.
-(void)update {
[tableView reloadData];
NSLog(@" %i", [tableData count]);
}
In nslog it is saved 1 when I add a row returning 2, but the table is not updated.
- (void) refresh:(id)sender {
NSString *jsonString = [NSString
stringWithContentsOfURL:[NSURL URLWithString:xmlDataUrl]
encoding:NSUTF8StringEncoding
error:nil];
SBJSON *parser = [[SBJSON alloc] init];
NSDictionary *results = [parser objectWithString:jsonString error:nil];
parser = nil;
[self setTableData:[results objectForKey:@"items"]];
[self performSelector:@selector(update) withObject:nil afterDelay:.2];
}
.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier];
}
NSDictionary *item = [tableData objectAtIndex:[indexPath row]];
[[cell textLabel] setText:[item objectForKey:@"title"]];
[[cell detailTextLabel] setText:[item objectForKey:@"descript"]];
[[cell detailTextLabel] setText:[item objectForKey:@"detail"]];
.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [tableData count];
}
Jones source
share