PDA

View Full Version : UISlider Value Changed / [sender value]??




Darkroom
Jun 28, 2009, 02:00 PM
what is the proper syntax to achieve this ultra simple action... grrr... what i have below apparently is incorrect. UISlider's value changed is connected to the action.


- (IBAction)changeAlpha:(id)sender
{
[self.mainView setAlpha:[sender value]];
}


Error: incompatible type for argument 1 of 'setAlpha'

writing either [sender intValue] or [sender floatValue] (depending on how the slider's values appear) causes a crash.

[edit] nevermind. i figured it out. sender of UISlider can't be generic type (interesting!)... has to be


- (IBAction)changeAlpha:(UISlider *)sender



PhoneyDeveloper
Jun 28, 2009, 02:28 PM
value is kind of an unfortunate name for UISlider to use for its value.

You either need to typecast the sender to UISlider or typecast value to CGFloat.

Darkroom
Jun 29, 2009, 05:38 AM
[deleted post]