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
Related
I have a UIWebView where i load a url. But it does not load full content. I have checked all possible forums for solution but couldn't find a breakthrough yet. Any help would be really appreciated? You can try out the below url yourself. Basically, the url is supposed to contain html5 content/player.
-(void)loadPlayerUrl
{
activityIndicatorView.hidden = NO;
NSURL* nsUrl = [NSURL URLWithString:#"http://watch.nimbletv.com/tv"]
NSURLRequest* request = [NSURLRequest requestWithURL:nsUrl cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:30];
[self.playerWebView loadRequest:request];
}
However, this works perfectly in safari or any other browser.
You should create ViewControllerWebPage
Then
- (void)viewDidLoad
{
[super viewDidLoad];
self.screenName = #"Info Ekran";
NSURL *mobileCreaURL = [NSURL URLWithString:#"http://mobilecrea.com/"];
NSURLRequest *myRequest = [NSURLRequest requestWithURL:mobileCreaURL];
[mobileCrea loadRequest:myRequest];
}
Also create new view, select your new custom class (ViewControllerWebPage) and than create UIWebView
Having such a bizarre issue with the UIWebView and I haven't been able to find a solution online. I have an iPad app that has a web view in it. Upon first install and run of the app, I try to load an education website. The web view just hangs and times out. I kill the app, I run it again, and it loads just fine. This one works fine which is also part of the education website. I'm pulling my hair out!
Some code:
-(void)viewDidAppear:(BOOL)animated
{
NSURL *websiteUrl = [NSURL URLWithString:#"http://my.tac.edu.au"];
NSURLRequest *urlRequest = [[NSURLRequest alloc]initWithURL: websiteUrl];
[self.webView loadRequest:urlRequest];
}
Works fine with www.tac.edu.au. I don't know what it is about that URL that makes it hang only when the app is first installed. You stop it, run it again (without uninstalling) and it comes up just fine. Any help would be appreciated.
:)
instead of view did appear , write the code in view will appear
-(void)viewWillAppear:(BOOL)animated
{
NSURL *websiteUrl = [NSURL URLWithString:#"http://my.tac.edu.au"];
NSURLRequest *urlRequest = [[NSURLRequest alloc]initWithURL: websiteUrl];
[self.webView loadRequest:urlRequest];
self.webview.delegate = self;
}
- (void)webViewDidStartLoad:(UIWebView *)webView{
//Start Activity Indicator
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
//End activity indicator
}
I am trying to make an iOS app and I need to add a web view but the issue is I get an error:
Duplicate declaration of method 'viewDidLoad'
- (void)viewDidLoad {
[super viewDidLoad];
NSString *fullURL = #"http://google.com";
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_viewWeb loadRequest:requestObj];
}
I am testing with google for now and when I develop the web site for the web view I will put the website in.
objective-C does not support method overloading, so you have to use different method names.I am sure you have two viewDidload methods implemented in your .m class so please try to remove one method
i have attached screen shot for your reference try to remove any one viewDidLoad method
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;
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,