我在下面有一個文本字段和按鈕以及一個webview。如何在webview中從json responseString獲取特定方法
當我在文本字段中輸入字符串並按搜索按鈕時,整個JSON響應字符串顯示在UIWebview
實例中。
所以我的要求是顯示一個特定的方法,匹配在文本字段中輸入的字符串。
即使我在文本字段中輸入任何字符串時,當我按下搜索按鈕時,它顯示webview中的所有內容。
是否可以從responseString中獲取特定的方法?
建議需要完成的更改。
.h文件中
IBOutlet UITextField *searchtextField;
UIWebView *webView;
}
-(IBAction)search;
@property (nonatomic, retain) UIWebView *webView;
.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];
}
其中是ü在此代碼的NSString * urlAddress = [NSString的stringWithFormat加入searchString的在urlAddress:@「http://api.kivaws.org/ ?V1 /貸款/ search.json狀態=籌款」,搜索字符串]; –
urlAddress中沒有任何%@格式stringWithFormat通過你可以添加搜索字符串 –
雅是url是api和輸出格式是在JSon..so wat改變我shd在代碼中作出? – Abhilash