gpt4 book ai didi

objective-c - 为什么我会收到此错误?在 Xcode

转载 作者:行者123 更新时间:2023-11-29 11:05:49 32 4
gpt4 key购买 nike

<分区>

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

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com