views:

227

answers:

2

I need to change slider colors in my iphone app, and I put This:

- (UISlider *)ratioSlider
{

        UIImage *stetchLeftTrack = [[UIImage imageNamed:@"grayslide.png"]
                                    stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0];
        UIImage *stetchRightTrack = [[UIImage imageNamed:@"grayslide.png"]
                                     stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0];
        [ratioSlider setThumbImage: [UIImage imageNamed:@"slider_ball.png"] forState:UIControlStateNormal];
        [ratioSlider setMinimumTrackImage:stetchLeftTrack forState:UIControlStateNormal];
        [ratioSlider setMaximumTrackImage:stetchRightTrack forState:UIControlStateNormal];

}

in the "myVIewController.m" file, like in the UICatalog apple example file. I've added all of the images and defined the slider, but all that comes up on the simulator is a normal slider, and the only error/warning in XCode is a warning saying "Warning: control reaches end of non-void function". How do I get this code to work?

+1  A: 

Well, the warning:

Warning: control reaches end of non-void function

Is because your not returning an object of type UISlider * based on your message signature:

- (UISlider *)ratioSlider
Mr-sk
I tried changing it to a void action, but the images still don't show up on the slider.
hephaestus042
A: 

I think you gone the wrong way around.

Instead of trying to change it to a void action, why don't you

return ratioSlider;

at the end of your method.

(Don't forget to checkout the viewDidLoad method on ControlsViewController.m in UICatalog to see how the customSlider is actually created, as this may also be confusing matters).

Eoin
I added a return `ratioSlider;` at the end, but it still doesn't work.In the `viewDidLoad` of UICatalog, there is: `[NSDictionary dictionaryWithObjectsAndKeys: @"UISlider", kSectionTitleKey, @"Customized Slider", kLabelKey, @"ControlsViewController.m:\r-(UISlider *)customSlider", kSourceKey, self.customSlider, kViewKey, nil],` I'm kind of a newbie at obj-c, so I'm not exactly sure what that means, but it looks like it's mostly defining text.Thanks for your help.
hephaestus042
did you add the ratioSlider @property in the .h file?
Eoin
the ratioSlider @property in the .h looks like this: `@property (nonatomic, retain, readonly) UISlider *ratioSlider;` - the only difference between it and the UICatalog file is the slider name(Which I changed everywhere else, too).
hephaestus042