Tutorial details

Random Image Generator | App Code for Sale | Preview

Random Image Generator | iOS Tutorial

How to create a random image generator

Overview PAGE TOP

Reference: http://www.geekylemon.com/WEBPROTECT-xcoderandomimagegener.htm

In this tutorial i will be showing you how to create a random image generator

Features:

  • 1 UIImageView
  • 1 round rect button

A random image generator is simply a function that displays a image randomly from a bunch of images in a single imageview its fun to use and can be a great feature to any app or game

ViewController.h PAGE TOP

@interface ViewController :UIViewController {
IBOutlet UIImageView *imageview;
}
-(IBAction)randomimagebutton; 
@end

ViewController. PAGE TOP

@implementation ViewController
-(IBAction)randomimagebutton {
int randomimages = rand() % 4;
switch (randomimages) {
case 0:
imageview.image = [UIImage imageNamed:@"lemon1.png"];
break;
case 1:
imageview.image = [UIImage imageNamed:@"lemon2.png"];
break;
case 2:
imageview.image = [UIImage imageNamed:@"lemon3.png"];
break;
case 3:
imageview.image = [UIImage imageNamed:@"lemon4.png"];
break;
default:
break;
    }
}
@end

Reference PAGE TOP

http://www.geekylemon.com/WEBPROTECT-xcoderandomimagegener.htm

0 Comments Leave a comment

Please login in order to leave a comment.

Newest first
!

Sign-in to your Chupamobile Account.

The Easiest way to Launch your next App or Game.

Join Chupamobile and get instant access to thousands of ready made App and Game Templates.

Creating an account means you’re okay with Chupamobile’s Terms of Service and Privacy Policy.