请帮助我!
我从Parse.com下载图像:
self.images = [[NSMutableArray alloc] init];
PFImageView *creature = [[PFImageView alloc] init];
PFQuery *query = [PFQuery queryWithClassName:@"SubCatergory"];
[query findObjectsInBackgroundWithBlock:^(NSArray *comments, NSError *error) {
for (PFObject *comment in comments) {
PFFile *file = [comment objectForKey:@"imageFile"];
creature.file = file;
creature.frame = CGRectMake(0, 0, 100, 100);
// creature.userInteractionEnabled =YES;
[creature loadInBackground];
//[self.images addObject:creature];
[self.images addObject: creature];
}
}];
将这些放在iCarousel中:
-(UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
PFImageView* img = [self.images objectAtIndex:index];
PFImageView* imgView = [[PFImageView alloc] initWithImage:img];
return img;
}
随着本地图像工作iCarousel罚款。我设置了委托和数据源。 我的图像数组的内容是这样的:
>”中, “
我收到了错误:
[PFImageView length]:无法识别的选择器发送到实例0xf40e9d0
答案 0 :(得分:1)
这是一个老问题,我认为您已经发现代码存在问题。简而言之,如果仔细观察:
PFImageView* img = [self.images objectAtIndex:index];
PFImageView* imgView = [[PFImageView alloc] initWithImage:img];
您正在使用img
,当您致电UIImageView
时,这实际上是UIImage
派生类,而不是initWithImage
。
这解释了你的崩溃。您可以安全地从[self.images objectAtIndex:index]
方法返回carousel:viewForItemAtIndex:
:
-(UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view {
return [self.images objectAtIndex:index];
}
答案 1 :(得分:0)
我希望它会帮助你,
self.images = [[NSMutableArray alloc] init];
PFQuery *query = [PFQuery queryWithClassName:@"SubCatergory"];
[query findObjectsInBackgroundWithBlock:^(NSArray *comments, NSError *error) {
for (PFObject *comment in comments) {
PFFile *post = [comment objectForKey:@"imageFile"];
[self.images addObject:post]; }
}];
-(UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view {
AsyncImageView *imageasy=[[AsyncImageView alloc] init];
[imageasy setImageURL:[NSURL URLWithString:[post url]]];
return imageasy.image;
}