0

Am using Xcode 4.5, targeting iOS5 and above. I am updating an app, using Storyboard for all scenes. Have a previous XIB and controller that I converted, but it is not functioning the same way. The controller allows changing the color of text and creating new colors. Creating new RGB colors relies on 3 Horizontal Sliders to change a swatch of color and the corresponding RGB values on 3 separate labels, before saving the new color. The sliders are Value Changed Sent Events and are hooked up to one action. The issue: when I change any of the sliders, ONLY the red label and red color value. I've tried changing the individual cases for the sliders into separate actions, and moving the setPreviewImage into a method of its own, but then, it does not change the swatch. Any help would be greatly appreciated. Thanks in advance.

-(IBAction)RGBSliderChange:(UISlider *)sender {
   switch ([sender tag])
  {
      case 0: {
         self.rLabel.text = [NSString stringWithFormat:@"%d", (int)[sender value]];
         break;
      }
      case 1: {
         self.gLabel.text = [NSString stringWithFormat:@"%d", (int)[sender value]];
         break;
      }
      case 2: {
         self.bLabel.text = [NSString stringWithFormat:@"%d", (int)[sender value]];
         break;
      }
      default:
         break;
  }
      self.colorPreviewImage.backgroundColor = [UIColor colorWithRed:(CGFloat)[self.rLabel.text floatValue]/256
           green:(CGFloat)[self.gLabel.text floatValue]/256
           blue:(CGFloat)[self.bLabel.text floatValue]/256
           alpha:1.0];
}
4

1 回答 1

0

I have solved this issue. It turns out that I did not have the tag set for each slider and label. They were all set to 0, hence any change only affected the Red color label. Setting each slider and label to a different tag solved the problem! Cheers!

于 2012-12-24T08:39:40.637 回答