views:

125

answers:

1

I am new to iphone app and pre-beginner of SDK programming. I have a flash file and need to reprogram for iphone.

The design of the app is a navbar with start buttom and an image view below them. I have 46 PNL images that I want to show in succession after the start button is clicked. Each picture will stay on the screen for 5 seconds.

I tried to replicate a code that i got off youtube but it did not work.

For the viewcontroller.h i used the following code verbatim and was able to link images (I call them ac) to the image view and also to establish a link for the start button:

{iboutlet uiimageview *ac; }

(dash) (ibaction)startclick:(id)sender;

For the viewcontroller.m I used the following concept but I received many syntax warnings:

NSarray List of 46 png files using @" notation for string Last png followed by nill Then some notation for length that each image appears.

If someone could help me out with the viewcontroller.h and viewcontroller.m to command this sort of animation, it would be much appreciated.

Marc

+1  A: 

You should use UIImageView's animationImages property to do this, with your button calling startAnimating and/or stopAnimating:

UIImage *frame1 = [UIImage imageNamed:@"frame1.png"];
UIImage *frame2 = [UIImage imageNamed:@"frame2.png"];
UIImage *frame3 = [UIImage imageNamed:@"frame2.png"];
UIImage *frame4 = [UIImage imageNamed:@"frame2.png"];

uiImageView.animationImages = [[NSArray alloc] initWithObjects:frame1, frame2, frame3, frame4, nil];
uiImageView.animationDuration = 1.0 // defaults is number of animation images * 1/30th of a second
uiImageView.animationRepeatCount = 5; // default is 0, which repeats indefinitely
[uiImageView startAnimating];

// [uiImageView stopAnimating];

If you can't work out the syntax of Objective-C, you're going to struggle to do pretty much anything related to iPhone development.

Nathan de Vries