开发者

How do I call a IBAction method from within another method

开发者 https://www.devze.com 2023-01-06 03:25 出处:网络
Hi I am trying to call a method from a method, I am getting incompatible type for slider changed on the code where I am calling the method from:

Hi I am trying to call a method from a method, I am getting incompatible type for slider changed on the code where I am calling the method from:

[self EVsliderChanged: (float)EVslider.value ];

I assume that means that float is not the right type for uislider.value? or perhaps it is expecting me to pass it something different, bellow is the psudo code from .m :

- (IBAction) EVsliderChanged:(UISlider *)sender {  
    // code I want to run if either EVSliderChanded or PickerView changes
}

- (void)pickerView:(UIPickerView *)secPicker didSelectRow:(NSInteger)row inComponent (NSInteger)component { 
 [self EVsliderChanged: (float)EVslider.value ];
}

I'm sure I'm doing someth开发者_运维技巧ing n00bishly wrong, could someone please explain whats going wrong and give me an example of how to do it right.

Thanks


EVsliderChanged: method expects UISlider as paramater, not its value - so your call should be

[self EVsliderChanged:EVslider ];

And slider's value to be retrieved inside the method.

P.S. Note also that method and ivar names in objective-c usually start with lower case - just a convention, but still...

0

精彩评论

暂无评论...
验证码 换一张
取 消