文本从 UITextField 到 UIWebView 函数
我想为 UIWebView 添加搜索 theWebView,并且我需要将 UIWebView 的搜索查询放入按钮的功能:
-(IBAction)searchButtonPressed:(id)sender{
[theWebView highlightAllOccurencesOfString:@"%@", searchR];
}
ViewController.h:
@interface ViewController : UIViewController <UIWebViewDelegate, UIScrollViewDelegate> {
IBOutlet UIWebView *theWebView;
IBOutlet UITextField *searchF;
IBOutlet UILabel *searchR1;
NSString *searchR;
}
@property (retain, nonatomic) IBOutlet UIWebView *theWebView;
@property (retain, nonatomic) IBOutlet UITextField *searchF;
-(IBAction)searchButtonPressed:(id)sender;
-(IBAction)clearHighlights:(id)sender;
ViewController.m:
#import "ViewController.h"
#import "SearchWebView.h"
@implementation ViewController
@synthesize theWebView;
@synthesize searchF;
-(IBAction)searchButtonPressed:(id)sender{
[searchF resignFirstResponder];
searchR = searchF.text;
searchR1.text = [[NSString alloc] initWithFormat:@"%@", searchR];
/*[theWebView highlightAllOccurencesOfString:@"%@", searchR];
[theWebView highlightAllOccurencesOfString:@"7019"];*/
}
-(IBAction)clearHighlights:(id)sender{
[theWebView removeAllHighlights];
}
这是我的尝试,但它不起作用!
请帮忙
I want to add search theWebView for UIWebView, and i need to put search query from UIWebView to the function of button:
-(IBAction)searchButtonPressed:(id)sender{
[theWebView highlightAllOccurencesOfString:@"%@", searchR];
}
ViewController.h:
@interface ViewController : UIViewController <UIWebViewDelegate, UIScrollViewDelegate> {
IBOutlet UIWebView *theWebView;
IBOutlet UITextField *searchF;
IBOutlet UILabel *searchR1;
NSString *searchR;
}
@property (retain, nonatomic) IBOutlet UIWebView *theWebView;
@property (retain, nonatomic) IBOutlet UITextField *searchF;
-(IBAction)searchButtonPressed:(id)sender;
-(IBAction)clearHighlights:(id)sender;
ViewController.m:
#import "ViewController.h"
#import "SearchWebView.h"
@implementation ViewController
@synthesize theWebView;
@synthesize searchF;
-(IBAction)searchButtonPressed:(id)sender{
[searchF resignFirstResponder];
searchR = searchF.text;
searchR1.text = [[NSString alloc] initWithFormat:@"%@", searchR];
/*[theWebView highlightAllOccurencesOfString:@"%@", searchR];
[theWebView highlightAllOccurencesOfString:@"7019"];*/
}
-(IBAction)clearHighlights:(id)sender{
[theWebView removeAllHighlights];
}
This is my try, but it don't work!
Help please
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论