ios - Downloading images from Parse.com and using them for iCarousel -
please me!
i download images parse.com this:
self.images = [[nsmutablearray alloc] init]; pfimageview *creature = [[pfimageview alloc] init]; pfquery *query = [pfquery querywithclassname:@"subcatergory"]; [query findobjectsinbackgroundwithblock:^(nsarray *comments, nserror *error) { (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]; } }];
put these in 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; }
with local images works icarousel fine. set delegates , datasource. content of images array this:
>", "
i got error:
[pfimageview length]: unrecognized selector sent instance 0xf40e9d0
this old question , think have found issue code. in short, if carefully:
pfimageview* img = [self.images objectatindex:index]; pfimageview* imgview = [[pfimageview alloc] initwithimage:img];
you using img
, uiimageview
derived class in place of uiimage
when call initwithimage
.
this explains crash. can safely return [self.images objectatindex:index]
carousel:viewforitematindex:
method:
-(uiview *)carousel:(icarousel *)carousel viewforitematindex:(nsuinteger)index reusingview:(uiview *)view { return [self.images objectatindex:index]; }
Comments
Post a Comment