It's been a few days since i've posted a tutorial, because i've been trying to think of basic things to do, that someone following my tutorials has the ability to understand. I've come up with this.

If this is your first time reading a tutorial, please go to the bottom of this thread for a link to all of my tutorials in order.

Today we'll be looking at making falling images in a basic iPhone view. So let's get started.

Start by creating a new project, selecting View Based or Single View, and naming it FallingImages.

Now, starting off, we're going to need an image to fall in the first place. I'll be using the one below, but you can use whatever you want. Just make sure it's in the .png format.



You'll need to drag the image to the Supporting Files folder of your project, located just under the left column with the .h, .m, and .storyboard files. Make sure the "Copy items into destination group's folder" option is checked and click Finish:



Now that we have our image inserted, we can go straight to our .h and begin inserting our code.

Start by adding a curly bracket right on the end of the @interface line, like shown below:



Next we'll be adding an IBOutlet and an NSTimer. Type this right below the @interface line:
Code:
	IBOutlet UIImageView *image ;
	NSTimer *moveObjectTimer ;
}
So now your .h should look like this:



The first line just tells Xcode that we have an image, that it's name is image, and that it's going to change somehow. The second line tells Xcode we'll be using an NSTimer, and that it's name is moveObjectTimer.

That's all of the coding we need in our .h, now we can move into our .m

To start in the .m, we'll define our NSTimer. Start by typing this right below the super viewDidLoad line, before it's closing bracket (if you don't understand where to put it, refer to the image below):
Code:
	moveObjectTimer = [NSTimer schedultedTimerWithTimeInterval:0.1 target:self selector:@selector(moveObject) userInfo:nil repeats:YES] ;
So now your .m should look like this:



Next we'll add this code:
Code:
-(void) moveObject {
	image.center = CGPointMake(image.center.x, image.center.y +5) ;
Your .m should now look like this:



Note the highlighted code, that's what we just added.

This tells Xcode that our image will be moving across the y and x axis (up/down and left/right) and that it will be moving at a speed of 5. You can change the +5 to whatever number you want to adjust the speed.

That's it for coding, now we can move into our .storyboard.

Start by dragging a UIImageView onto your view:





Next select the image view, open the Attributes Inspector, the fourth right arrow on the right column, and select the image browse box at the top.



Mine is called red-ball.png, but yours will be whatever you named the image you chose. Unless you want your image to fill the entire screen, resize it to be a bit smaller. I made mine 77 x 77.



Next select your entire view so that the iPhone image is highlighted blue, and click on the Connections Inspector, the last arrow in the right column, open the Outlets subheading, and drag the image option to your image.



Now you can click Run, and see if you coded it correctly. If everything was done right it should run smoothly and your image simply fall out of the view.

Thanks for reading, post any questions, problems, or concerns you have below, and be sure to check out my other tutorials here!