Webview loading weburl show replaced images from one place to another - ios

I am using UIWebview to load a weburl, which contains few images and text. But after loading the url on webview images gets replaced with one another on some devices.
Is it problem with webpage?
My Code is here
NSURL *url=[[NSURL alloc]initWithString:_url];
NSURLRequest *request=[NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
I have attach link to the actual loaded webview.
this image actually appears to some other location but right now it gets loaded to this place

Try to this one , it may help you..!!
https://github.com/AdrianFlorian/AFImageViewer
Images url are old, please replace with other like:
#image url: http://www.citi.io/wp-content/uploads/2015/10/1291-01-bruges-meteoweb.eu_.jpg
-(NSArray *)imageUrls
{
return [NSArray arrayWithObjects:
[NSURL URLWithString:#"http://imgs.mi9.com/uploads/landscape/4717/free-the-seaside-landscape-of-maldives-wallpaper_422_84903.jpg"],
[NSURL URLWithString:#"http://pics4.city-data.com/cpicc/cfiles42848.jpg"],
nil];
}

Related

Load local file UIWebview before transition

I searched alot for this but couldnt find a perfect answer.
My Ios app has its every page in UIWebview.
The only problem I am facing is when transiting from one page to another, the loading of UIWebview takes 1-2 seconds and the user sees a white background. Since all the html, css, image files are stored locally, how can I preload the UIWebview before transition? So that the user gets native feel.
I am loading the URL this way :
[self.navigationController setNavigationBarHidden:YES];
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"start" ofType:#"html" inDirectory:#"main/html"]];
NSString *path = [url absoluteString];
NSURL *filePath = [NSURL URLWithString:[NSString stringWithFormat:#"%#%#",path,#"?logged_in=1"]];
[self.webView loadRequest:[NSURLRequest requestWithURL:filePath]];
I am using a different viewcontroller for each page as I want the native push and modal transitions.

URL does not load in UIWebView but gets loaded into safari browser

I am loading one URL in UIWebView. It calls webViewDidFinishLoad delegate method but load an error page.
To load URL, I have used below code:
[customwebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:customURL]]];
Then I tried same URL in the Safari browser and it gets perfectly loaded.
This is the case only with iPhone4 with iOS 7.1.2.
I tried in simulator and device. Result is same.
Is there anything I need to set manually to load URL in UIWebView which is bydefault ON in Safari?
i was also not able to load urls like Facebook share dialog and twitter share.
But i got it fixed by encoding the url
use this :
NSString *encoded = [self.link stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:encoded]];
self.webView.delegate = self;
[self.webView loadRequest:request];

iOS view PDF from a given url inside of an app

I want to open and show a pdf file from a given url (somewhere in the internet) and view it in my iOS application. Could you please tell me what are the possible approaches to this problem, and list their advantages and disadvantages / limitations? I've heard about UIWebView, are there any other options?
My suggestion is using the webview.
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
NSURL *url = [NSURL URLWithString:#"https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/ProgrammingWithObjectiveC.pdf"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webview loadRequest:request];
}
If you want to more information please refer the follwing link as well
https://developer.apple.com/library/ios/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf/dq_pdf.html

UIWebView staying blank until I hard code the URL

I am writing an App where I pass a Link as a NSString from a TableView to my DetailView. The String gets passed correctly, as I can see it in the log. The problem is, that the WebView just stays blank; unless I hard code any URL in. Even the ones that I can see in the log by just copy pasting them. What am I missing? Any help is greatly appreciated. Here's a sample log output and my code. I also checked this thread, where the guy hab the exact same problem as me, but none of the solutions posted there where helpful. UIWebView not loading URL when URL is passed from UITableView
2013-06-17 13:19:52.147 Feuerwehr[1661:c07] http://oliverengelhardt.de/ffw_app/Einsaetze/GB0505/index.html
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *urlString = url;
NSURL *myURL = [NSURL URLWithString:urlString];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:myURL];
[webView loadRequest:requestObj];
NSLog(urlString);
}
I think you stringUrl is nil when it loads (so it doesn't get passed. Break point view did load and see the value of the urlstring
Based on what you've said, your url isn't formatted correctly
i think you are missing delegate
self.webView.delegate = self;

How to load a UIWebView when click a button in another view in ios

I want to create an ios application which incuding a UIWebview. I saw so many tutorials that saying how to load webview when start the application. But what I want is when user click on a link in one View,the web page should be loaded in seperate View. This is the code in my button click event.
`
-(IBAction)visitWeb:(id)sender{
web *wb=[[web alloc]initWithNibName:nil bundle:nil];
[self presentModalViewController:wb animated:YES];
[wb release];}
This is in web
`
- (void)viewDidLoad {
NSString *urlAddress = #"http://www.google.com";
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
[super viewDidLoad]; }
But it not display anything. Just display the empty UIWebView What is the reason for it.plz give me a solution with the code.
Thanks,

Resources