Possible Duplicate:
I have two error : No visible @interface for ‘UIWebview’
Why I get this error at Xcode. Error is that:No visible @interface for ‘UIWebView’ declares the selector ‘highlightAllOccurencesOfString:’ and No visible @interface for ‘UIWebView’ declares the selector ‘removeAllHighlights’. Where are wrong?
WBSecondViewController.h
#import <UIKit/UIKit.h>
@interface WBSecondViewController : UIViewController <UIWebViewDelegate, UIScrollViewDelegate>{}
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@property (weak, nonatomic) IBOutlet UIToolbar *webToolBar;
- (IBAction)searchButtonPressed:(id)sender;
- (IBAction)clearHighlights:(id)sender;
- (NSInteger)highlightAllOccurencesOfString:(NSString*)str;
- (void)removeAllHighlights;
@end
WBSecondViewController.m
#import "WBSecondViewController.h"
@interface WBSecondViewController ()
@end
@implementation WBSecondViewController
-(IBAction)searchButtonPressed:(id)sender{
NSLog(@"highlighttes");
[_webView highlightAllOccurencesOfString:@"不明"];
}
-(IBAction)clearHighlights:(id)sender{
[_webView removeAllHighlights];
}
- (NSInteger)highlightAllOccurencesOfString:(NSString*)str
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"UIWebViewSearch" ofType:@"js"];
NSString *jsCode = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
[_webView stringByEvaluatingJavaScriptFromString:jsCode];
NSString *startSearch = [NSString stringWithFormat:@"uiWebview_HighlightAllOccurencesOfString('%@')",str];
[_webView stringByEvaluatingJavaScriptFromString:startSearch];
NSString *result = [_webView stringByEvaluatingJavaScriptFromString:@"uiWebview_SearchResultCount"];
return [result integerValue];
}
- (void)removeAllHighlights
{
[_webView stringByEvaluatingJavaScriptFromString:@"uiWebview_RemoveAllHighlights()"];
}
@end
These two lines are wrong,
It should be,
You are trying to call
highlightAllOccurencesOfStringandremoveAllHighlightswhich are defined inWBSecondViewController‘s@interfacebut onUIWebviewobjects. Compiler is not able to find it inUIWebViewclass@interfaceand hence the error message asNo visible @interface for 'UIWebView' declares the selector ...