0

データを取得するために Parse.com を使用しています。pf クエリを使用して解析から画像を取得したいのですが、アプローチが機能しません。UIImageView の場所に何も表示されません。これが私のコードです:

    PFQuery *query = [PFQuery queryWithClassName:@"Class"];
        [query whereKey:@"Yes or No" equalTo:[NSNumber numberWithBool:YES]];
        [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {


            if (!error) {
                // The find succeeded.
                NSLog(@"Successfully retrieved %d scores.", objects.count);



                for (int i = 0; i < objects.count; i++) {

                    object = [objects objectAtIndex:i];

                    NSString *Property1 = [object objectForKey:@"Property1"];

                    __block UIImage *MyPicture = [[UIImage alloc]init];


                    PFFile *imageFile = [object objectForKey:@"Resimler"];
                    [imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error){
                        if (!error) {
                         MyPicture = [UIImage imageWithData:data];

                        }
                    }];

aClass *AC = [[aClass alloc]initWithProperty:Propert1 Picture:MyPicture];
                    [self.MyArray addObject:AC];



  }

            }


        } else {
            // Log details of the failure
            NSLog(@"Error: %@ %@", error, [error userInfo]);
        }


    }];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    MyViewViewCell *cell = (MyViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    if (cell == nil)
    {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"Cell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }


    aClass *mC = [self.MyArray objectAtIndex:indexPath.row];

    cell.Label.text = mC.Property;

    cell.myImage.image = mC.Picture;
    return cell;
}

編集:

At aClass.h
@interface aClass : NSObject
@property(strong)NSString *Property;

@property(strong)UIImage *Resim;

-(id)initWithProperty:(NSString *)aProperty Picture:(UIImage *)aPicture ;
@end

at aClass.m


@implementation Mekan
@synthesize Property, Picture;

-(id)initWithMekanIsmi:(NSString *)aProperty Picture:(UIImage *)aPicture{
    self=[super init];
    if(self){
        self.Property = aProperty;
        self.Picture = aPicture;
    }
    return self;

}
@end

私はそれが大規模なコードであることを知っていますが、myImage を割り当てる場所を示すためにこれらのコードを記述する必要があります。分からないところは質問できるので

4

1 に答える 1

0

私はこのようにします:

UIImageView *imageView = [[UIImageView alloc] initWithImage:@"default.png"];
[userIcon getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
  imageView.image = [[UIImage alloc] initWithData:data];
} progressBlock:^(int percentDone) {
    // update progress
}];

UIImageに適切に割り当てているようですが、その画像をUIImageViewの画像として設定することはありません。

于 2013-05-19T17:15:55.073 に答える