Case Study: Implementing Content Search in UIWeb View in iOS App

Case Study: Implementing Content Search in UIWeb View in iOS App

0
Shares
Case Study: Implementing Content Search in UIWeb View in iOS App
Rate this post

Problem/Issue:  We wanted to highlight particular word in UIWeb View Control; in short we can say that we wanted to implement “Content Search” features in the application.

  • Solution/Steps flow by you: I got some link from there I download one java script file and integrate in my Application. After integration that file I got solution for my feature. (For this feature your content must be store in html format).
  • Reference link: Click this
  • Sample code which you have written

/*
-(void)search_highlited
{
[self highlightAllOccurencesOfString:[AppDelegate appDelegate].str_content_search];
}
– (NSInteger)highlightAllOccurencesOfString:(NSString*)str
{
// The JS File
NSString *filePath  = [[NSBundle mainBundle] pathForResource:@”UIWebViewSearch” ofType:@”js” inDirectory:@””];
NSData *fileData    = [NSData dataWithContentsOfFile:filePath];
NSString *jsString  = [[NSMutableString alloc] initWithData:fileData encoding:NSUTF8StringEncoding];
//NSLog( @” view of tag OF tag both =%@”,getImageView1);
[web_detail stringByEvaluatingJavaScriptFromString:jsString];
[jsString release];

// The JS Function
NSString *startSearch   = [NSString stringWithFormat:@”uiWebview_HighlightAllOccurencesOfString(‘%@’)”,str];
[web_detail stringByEvaluatingJavaScriptFromString:startSearch];
result    = [web_detail stringByEvaluatingJavaScriptFromString:@”uiWebview_SearchResultCount”];
return [result integerValue];
}
*/

  • Screen shot:
Implementing Content Search in UIWeb View in iOS App

Name of Application on iTunes: Healing with Foods

Contributed by: Keyur Bhalodiya, iPhone App Developer at Space-O Technologies. 

 
0
Shares
 

Have an App Idea?

Get your free consultation now