Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want to change the image on click following code might be useful. Otherwise if you want to change them dynamically use the code in Action method with NSTimer delegate method.</p> <pre><code>Drag and drop some images in bundle and pass their names to array. singleton .h file #import &lt;Foundation/Foundation.h&gt; @interface SingleTon : NSObject { } +(SingleTon *) createSingleTon; -(NSString *) returnImage:(NSString *) imageIs; @end singleton .m file @implementation SingleTon +(SingleTon *) createSingleTon { static SingleTon *single= nil; if (single == nil) { single = [[SingleTon alloc] init]; } return single; } -(NSString *) returnImage:(NSString *) imageIs { return imageIs; } @end viewcontroller .h file #import &lt;UIKit/UIKit.h&gt; #import "SingleTon.h" @interface ViewController : UIViewController&lt;UITextFieldDelegate&gt; { SingleTon *sing; IBOutlet UIImageView *displayImage; // connect this outlet imageview in xib. NSArray *imagesArray; int i; } -(IBAction)changeImage:(id)sender; @end </code></pre> <p>viewcontroller .m file</p> <pre><code>#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; imagesArray = [[NSArray alloc] initWithObjects:@"images.jpg",@"images1.jpg",@"images2.jpg",@"images4.jpg", nil]; i = 0; sing = [SingleTon createSingleTon]; // Do any additional setup after loading the view, typically from a nib. } -(IBAction)changeImage:(id)sender { if (i&lt;[imagesArray count]) { displayImage.image = [UIImage imageNamed:[sing returnImage:[imagesArray objectAtIndex:i]]]; } i++; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload