私はUITebleView
衣装を持っていUITableViewCells
ます。それらを更新するたびに、コンテンツ自体が並べ替えられます。誰かが理由を知っていますか?
私は JSON からデータを取得しています。ある種の並べ替えは行っていません。TableViewCell indexpath.row に従ってデータを表示するだけです。
そして、これは私が UITableViewCell コンテンツを設定したコードです:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *costumeCell = @"Cell";
StoreCell *cell = [tableView dequeueReusableCellWithIdentifier:costumeCell];
if (!cell) {
cell = [[StoreCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:costumeCell];
}
NSDictionary *dict;
dict = [application objectAtIndex:indexPath.row];
[downloadQueue addOperationWithBlock:^{
name = [dict objectForKey:@"name"];
detileName = [dict objectForKey:@"detailName"];
itmsLink = [dict objectForKey:@"itms-serviceLink"];
icon = [dict objectForKey:@"icon"];
developer = [dict objectForKey:@"developer"];
version = [dict objectForKey:@"version"];
category = [dict objectForKey:@"category"];
rating = [dict objectForKey:@"rating"];
ratingNumbers = [dict objectForKey:@"ratingNumber"];
description = [dict objectForKey:@"description"];
developerEmails = [dict objectForKey:@"developerEmail"];
cell.AppName.text = name;
cell.category.text = category;
cell.rater.text = [NSString stringWithFormat:@"(%@)", ratingNumbers];
if ([rating intValue] == 1) {
cell.rating.image = [UIImage imageNamed:@"1.png"];
}
if ([rating intValue] == 2) {
cell.rating.image = [UIImage imageNamed:@"2.png"];
}
if ([rating intValue] == 3) {
cell.rating.image = [UIImage imageNamed:@"3.png"];
}
if ([rating intValue] == 4) {
cell.rating.image = [UIImage imageNamed:@"4.png"];
}
cell.itms = itmsLink;
[NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:icon]] queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse* response, NSData* data, NSError* error){
if(error)
{
// Error Downloading image data
cell.AppIcon.image = [UIImage imageNamed:@"placeholder.png"];
}
else
{
[cell.AppIcon setImage:[UIImage imageWithData:data]];
}
}];
cell.AppIcon.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:icon]]];
cell.number.text = [NSString stringWithFormat:@"%li", (long)indexPath.row + 1];
}];
cell.AppIcon.layer.masksToBounds = YES;
cell.AppIcon.layer.cornerRadius = 16.0;
cell.installButton.layer.masksToBounds = YES;
cell.installButton.layer.cornerRadius = 5.0f;
cell.installButton.layer.borderColor = [UIColor darkGrayColor].CGColor;
cell.installButton.layer.borderWidth = 1.0f;
return cell;
}