从UITextField到UIWebView函数的文本

时间:2011-10-17 17:08:48

标签: ios uiwebview uitextfield

我想为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];

}

这是我的尝试,但它不起作用!

请帮助

0 个答案:

没有答案