简体   繁体   English

我如何从另一个方法中调用IBAction方法

[英]How do I call a IBAction method from within another method

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? 我假设这意味着float不是uislider.value的正确类型? or perhaps it is expecting me to pass it something different, bellow is the psudo code from .m : 也许是希望我通过它不同的东西,下面是.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 something 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 EVsliderChanged:方法期望UISlider为参数,而不是其值-因此您的调用应为

[self EVsliderChanged:EVslider ];

And slider's value to be retrieved inside the method. 并在方法内部检索滑块的值。

PS Note also that method and ivar names in objective-c usually start with lower case - just a convention, but still... PS请注意,objective-c中的方法和ivar名称通常以小写开头-只是一个约定,但仍然...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM