I have one class UIViewController and Inside I have one button , I want to call one method from another class
would you please help me to implement the action for my button
I’m new to objective-c
my button Action in UIViewController:
- (IBAction)ActionButton:(id)sender {
NSLog(@"A1");
}
my method in WebViewController:
-(void)loadWebView{
NSURL *url = [NSURL fileURLWithPath:[ [ NSBundle mainBundle ] pathForResource:
@"TestName/TestName1/Test1Name1" ofType:@"html" ]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
}
my question is how to call this method to my button since it’s in another view?
I have one method in my WebViewController and I want to call it from one button that I have in UIViewController
You could try this:
Say you have a class called
ViewAwhich implements the method.If you want the button action to invoke that method, you need to have an instance of another class.
For you button VIEW:
Your Button method: