Calling the (IBAction) method from another class [closed]
Question
I need to call the IBAction method from the another class.
I am having the -(IBAction) addButtonPressed:(id)sender for button pressed action but i need the same function to be called in another method in some other class.
Solution
Why you create the method with IBAction. just create a button from code and set selector to your method. Then you can easily access the method from another class.
here I'm showing you code how to create a button with selector.
buttonImage = [UIImage imageNamed:@"bak.png"];
UIButton *newCardBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[newCardBtn addTarget:self action:@selector(addButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
then you Simply declare the method as
-(void) addButtonPressed:(UIButton *)sender {}
and then you can access this method from another class
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow