objective c - animating a series of images using iteration and array -
i have been playing around xcode lately , stuck @ stupid problem. need help! okay added 69 images supporting files names 1.jpg,2.jpg...69.jpg. named because loop used create animation displaying series of images. here did. header file:
#import <uikit/uikit.h> @interface mybitchviewcontroller : uiviewcontroller{ nsmutablearray *images; } @property (retain, nonatomic) nsmutablearray *images; @end
and implementation file:
#import "mybitchviewcontroller.h" @implementation mybitchviewcontroller @synthesize images; - (void)viewdidload { (int imagenumber = 1; imagenumber <= 69; imagenumber++) { nsmutablestring *mystring = [nsmutablestring stringwithformat:@"%i", imagenumber]; [mystring stringbyappendingstring:@".jpg"]; [images addobject:[uiimage imagenamed:mystring]]; } cgrect frame = cgrectmake(0.0, 0.0, 320.0, 460.0); uiimageview *imageview = [[uiimageview alloc] initwithframe:frame]; imageview.animationimages = images; imageview.contentmode = uiviewcontentmodescaleaspectfit; imageview.animationduration = 3; imageview.animationrepeatcount = 0; [imageview startanimating]; [self.view addsubview:imageview]; [imageview release]; [super viewdidload]; } - (void)viewdidunload { [super viewdidunload]; // release retained subviews of main view. } - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { return (interfaceorientation != uiinterfaceorientationportraitupsidedown); } @end
now issue program doesn't throw error when simulator runs shows blank grey screen instead of animation. going wrong?
it nsmutablearray* images;
never created. way, doesn't need property, should create local variable in viewdidload
- otherwise you'll keep adding more , more images each time view loads.
Comments
Post a Comment