Thursday 17 April 2014

Load URL in UIWebView with special character , append some string with bellow code.

Here you can add any code or string in your local file url with bellow code.

if your url like user/.../filename.htm and if you want to add some hash code of word after that url like user/.../filename.htm#green then you can use my bellow function.

-(void)loadWebView{
    NSString *path;
NSBundle *thisBundle = [NSBundle mainBundle];
path = [thisBundle pathForResource:@"filename" ofType:@"html"];//here write your file name and its extention
    NSURL *url = [NSURL fileURLWithPath:path];
    NSURL *fullURL = [NSURL URLWithString:@"#green" relativeToURL:url];//pass any code or string with append in url baseurl like this
    [yourWebView loadRequest:[NSURLRequest requestWithURL:fullURL]];
    [yourWebView setBackgroundColor:[UIColor clearColor]];
    [yourWebView setOpaque:NO];

}

No comments:

Post a Comment