0
私はUISlider
の画像をUIImageView
の画像にコントロールしようとしています。スライダの最小値は0、最大値は50です。UISliderはUIImageViewを制御します
はelse
とchosenTime = 50
にしか反応しません。 対応する画像のみがUIImageView
に表示されます。 48と49は無視されます。この場合、「else」画像が表示されます。 ご迷惑をおかけして申し訳ありません。
-(IBAction) sliderChanged:(id)sender{
UISlider *slider = (UISlider *) sender;
int prog = (int)(slider.value + 0.5f);
NSString * newText = [[NSString alloc] initWithFormat:@"%d", prog];
sliderLabel.text = newText;
int chosenTime = [newText intValue];
NSLog(@"chosenTime is %i", chosenTime);
//chosenTime is confirmed int value in the NSLOG!!!
if (chosenTime == 1) {
NSString *fullpath = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/Pic0001.png"];
clockView.image = [UIImage imageWithContentsOfFile:fullpath];
}
if (chosenTime == 48) {
NSString *fullpath = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/Pic0048.png"];
clockView.image = [UIImage imageWithContentsOfFile:fullpath];
}
if (chosenTime == 49) {
NSString *fullpath = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/Pic0049.png"];
clockView.image = [UIImage imageWithContentsOfFile:fullpath];
}
if (chosenTime == 50) {
NSString *fullpath = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/Pic0050.png"];
clockView.image = [UIImage imageWithContentsOfFile:fullpath];
} else {
NSString *fullpath = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/Pic0000.png"];
clockView.image = [UIImage imageWithContentsOfFile:fullpath];
}
}
ありがとう、素晴らしい学習の瞬間! – Giel