I have a view with one UIImageView and a slider. Slider Min 1 Max 10. When slider is moved UIImageView should display a different image. Slider is 1 test1.png will display, slider is 2 test2.png will display, slider is 3 test3.png will display etc...
In Interface Builder I have connected IBOutlet slider to Horizontal slider, IBOutlet image to Image View, & IBAction changeImage to Horizontal slider "Value Changed"
I've cast slider float to int. Placed an NSLog statement in IBAction changeImage to make sure method is being called, It is. I receive no error messages on build. However, when i build & Run and move slider in simulator image in UIImageView does not change. The problem must be "logic" I've hit a wall and can not figure it out.
#import <UIKit/UIKit.h>
@interface SliderViewController : UIViewController {
IBOutlet UISlider *slider;
IBOutlet UIImageView *image;
}
@property (nonatomic, retain) IBOutlet UISlider *slider;
@property (nonatomic, retain) IBOutlet UIImageView *image;
- (IBAction)changeImage;
@end
#import "SliderViewController.h"
@implementation SliderViewController
@synthesize slider;
@synthesize image;
- (IBAction)changeImage {
NSLog(@"changeImage method being called!!!!");
int intSlider = (int)(slider.value);
if (intSlider == 0) {
image.image = [UIImage imageNamed:@"ash1.png"];
}
if (intSlider == 1) {
image.image = [UIImage imageNamed:@"ash2.png"];
}
if (intSlider == 2) {
image.image = [UIImage imageNamed:@"ash3.png"];
}
if (intSlider == 3) {
image.image = [UIImage imageNamed:@"ash4.png"];
}
if (intSlider == 4) {
image.image = [UIImage imageNamed:@"ash5.png"];
}
if (intSlider == 5) {
image.image = [UIImage imageNamed:@"ash6.png"];
}
if (intSlider == 6) {
image.image = [UIImage imageNamed:@"ash7.png"];
}
if (intSlider == 7) {
image.image = [UIImage imageNamed:@"ash8.png"];
}
if (intSlider == 8) {
image.image = [UIImage imageNamed:@"ash9.png"];
}
if (intSlider == 9) {
image.image = [UIImage imageNamed:@"ash10.png"];
}
if (intSlider == 10) {
image.image = [UIImage imageNamed:@"ash11.png"];
}
}