ios - Loop through array contents' names -
i want display .gif (so automatically playing video), therefore found out need use array of uiimages. now, have video containing 96 images, use loop naming them. possible?
i tried following, unfortunatly not work:
for (int = 0; i<97; i++) { [uiimage imagenamed:@"%d", i]; } so want loop this:
nsarray *myarray = [nsarray arraywithobjects: (int = 0; i<97; i++) { [uiimage imagenamed:[nsstring stringwithformat:@"%d",i]]; } , nil]; so there way using for-loops in array? ideas?
create property in .h file :
@property(nonatomic, strong) nsmutablearray *images; initialise in viewdidload method :
- (void)viewdidload { [super viewdidload]; self.images = [[nsmutablearray alloc] init]; } you need following :
for (int = 0; i<97; i++) { uiimage *currentimage = [uiimage imagenamed:[nsstring stringwithformat:@"%d",i]]; [self.images addobject:currentimage];// images nsmutablearray } if want animate images, can following (assuming have uiimageview object name imageview) :
imageview.animationimages = self.images; [imageview startanimating]; go through uiimageview class documentation more options.
Comments
Post a Comment