Reputation: 11
I have a scenario when the document takes time to download in a webview , user can press a cancel button provided in the activity indicator and can stop the downloading. I am using a different library for activity indicator. I need to know in webview that the button has been clicked in activity indicator or how can I have access to webview in activity indicator library. Can I set the activity indicator cancel button selector method in some other file? Quick help is much appreciated.
Upvotes: 0
Views: 293
Reputation: 1374
You can use NSNotificationCenter for get the Cancel button pressed event:
Add Observer
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(cancelButtonClicked:) name:@"cancelButton" object:nil];
Implement Cancel method
-(void)cancelButtonClicked:(NSNotification *)notification{
// Do your action here
}
And also don't forget to remove observer once done with cancel:
[[NSNotificationCenter defaultCenter] removeObserver:self];
For detail check this one :
Send and receive messages through NSNotificationCenter in Objective-C?
Upvotes: 0
Reputation: 9484
You can either use Delegation
or Notification
to tell the Class that contains UIWebView that cancel button has been pressed in another class(your Activity Indicator class).
Upvotes: 1