iphone - Error: Variable-sized object may not be initialized. But why? -
enter code hereint quantity = [array count]; int i; (i=0; i<quantity; i++) { nsstring *imagename = [nsstring stringwithformat:@"car_%@.jpg", [[array objectatindex:i] objectforkey:@"carname"]] ]; uiimage *img[i] = [uiimage imagenamed:imagename]; uiimageview *imgview[i] = [[uiimageview alloc] initwithimage:img[i]]; imgview[i].frame = cgrectmake(i*kwidth, 0, kwidth, kheight); [scrollview addsubview:imgview[i]]; [imgview[i] release]; }`enter code here`
error: variable-sized object may not initialized. why?
you may want try this:
int i; (i=0; i<quantity; i++) { nsstring *imagename = [nsstring stringwithformat:@"car_%@.jpg", [[array objectatindex:i] objectforkey:@"carname"]] ]; uiimage *img = [uiimage imagenamed:imagename]; uiimageview *imgview = [[uiimageview alloc] initwithimage:img]; imgview.frame = cgrectmake(i*kwidth, 0, kwidth, kheight); [scrollview addsubview:imgview]; [imgview release]; }
you don't need use img[i] in order populate scrollview uiimageview.
Comments
Post a Comment