简体   繁体   English

如何从WebView中的json responseString获取特定方法

[英]how to fetch particular method from a json responseString in webview

I have a text field and button and a webview below. 我在下面有一个文本字段和按钮以及一个webview。

When I enter the string in a text field and press search button, the entire JSON response string is displaying in UIWebview instance. 当我在文本字段中输入字符串并按搜索按钮时,整个JSON响应字符串将显示在UIWebview实例中。

So my requirement is to display a particular method that matches the string entered in the textfield. 因此,我的要求是显示与文本字段中输入的字符串匹配的特定方法。

even though i am entering any string in textfield when i press search button its displaying all contents in webview. 即使我在按搜索按钮时在文本字段中输入任何字符串,它也会在webview中显示所有内容。

is it possible to fetch particular method from responseString ? 是否可以从responseString获取特定方法?

Suggest changes that need to be done. 建议需要做的更改。

.h file .h文件

    IBOutlet UITextField *searchtextField;

    UIWebView *webView;
}

-(IBAction)search;

@property (nonatomic, retain)  UIWebView *webView;

.m file .m文件

-(IBAction)search
{
    NSString *searchString=searchtextField.text;    

    NSString *urlAddress = [NSString stringWithFormat:@"http://api.kivaws.org/v1/loans/search.json?status=fundraising",searchString];
    NSURL *url = [NSURL URLWithString:urlAddress];

    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

    [webView loadRequest:requestObj];
}

Just Place %@ in place of searchString where you want to add...This is all about from your end because I dont know where you want to add 只需将%@替换为您要添加的searchString即可...这一切都是从您的末尾开始的,因为我不知道您要添加的位置

Example

NSString *searchString=searchtextField.text;    

NSString *urlAddress = [NSString stringWithFormat:@"http://api.kivaws.org/v1/loans/search.json?status=%@",searchString];

Try It out.... 试试看....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM