How to set notification in iPhone
I have create a custom UIWebVie开发者_如何学JAVAw. On some class if I include my custom UIWebView, I need know if web view load is complete or not. I can get this in custom class using webViewDidFinishLoad, but how do I transfer this to Main view where I have add this Custom UIWebView. I need to enable some button when WebView is loaded.
I hope u can understand. Thanks
I think the good solution is to create a delegate pattern. You can pass the class (that include UIWebView) as a delegate, then when the UIWebView finish, you just need to call back that class to notify
In your custom UIWebView:
UIMyWebView.h:
@property (nonatomic, assign) id delegate;
@property (nonatomic, assign) SEL callback;
- (id)initWithDelegate:(id)delegate callback:(SEL)callback;
UIMyWebView.m:
- (id)initWithDelegate:(id)aDelegate callback:(SEL)aCallback {
delegate = aDelegate;
callback = aCallback;
}
- webViewDidFinishLoad {
[delegate performSelector:callback];
}
YourCaller.m:
- finishLoading {
// do something when finish loading
}
- myMethod {
UIMyWebView *webView = [[UIMyWebView alloc] initWithDelegate:self callback:@selector(finishLoading)];
}
精彩评论