作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<分区>
Possible Duplicate:
I have two error : No visible @interface for ‘UIWebview’
为什么我在 Xcode 中收到此错误。错误是:“UIWebView”没有可见的@interface 声明选择器“highlightAllOccurencesOfString:”并且“UIWebView”没有可见的@interface 声明选择器“removeAllHighlights”。哪里错了?
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
我是一名优秀的程序员,十分优秀!