I have been using AMSlidemenu with multiple AMSlideMenuContentSegues.
They all work fine at the moment as they just display a label.
The first view controller I have added a web view and given it its own custom class .h and .m file which point to a url but every time I launch the application crashes.
.....
- (void)viewDidLoad
{
NSURL *url = [NSURL URLWithString:#"http://google.com"];
NSURLRequest *requestURL = [NSURLRequest requestWithURL:url];
[websiteWebview loadRequest:requestURL]; **Thread 1: Breakpoint 1.1**
[super viewDidLoad];
// Do any additional setup after loading the view.
}
......
I dont understand whats happening ... I m a novice when it comes to Xcode so any help will be appreciated.
I hope I have contextualized my problem.
Related
From firstViewController I send a url to load on secondViewController. The url loads correctly. They, I press cancel button to go back to firstViewController:
[self dismissViewControllerAnimated:YES completion:nil];
Then again if I come back to secondViewController from firstViewController, I see a blank space with horizontal scrollbar.
I've used the following code to load url:
NSString *urlAddress = #"http://www.apple.com";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[self.myWebView loadRequest:requestObj];
I've implemented webview delegate methods and they are being called without any problem. for example following methods are called:
– webViewDidStartLoad:
– webViewDidFinishLoad:
Even there is no error to load and I've printed html source codes in -webViewDidFinishLoad and it Logged right codes.
My device iOS version is: iOS 9.3.2
Update:
The same app works well on my simulator. But doesn't work on real device.
I m just trying to fix all the contents of html according to the device screen.
I have to put html data at proper place for iPhone & iPad in webview.
Please help me!!!
I am going to assume that this question is a very basic one.
Suppose that you have placed a UIWebView in a view in your storyboard, and you have set layout constraints so that the UIWebView fills the view.
Then
Add an IBOutlet to your view controller, and connect it to the web view.
In the view controllers viewDidLoad: method, tell the web view what to display. Here is an example:
-(void)viewDidLoad {
[super viewDidLoad];
NSURL* url = [NSURL URLWithString:#"http://www.apple.com"];
NSURLRequest* r = [NSURLRequest requestWithURL:url];
[_webView loadRequest:r];
}
This loadRequest: call is asynchronous, meaning that the page may not show up immediately.
If this is not answering your question, please add more information.
I have a UIViewController with a UIWebView where I'm placing a PDF.
The issue I'm facing is when I click on a table cell to show the PDF it does not show the first time however if i go back to the table and click on the cell again it appears.
I call the PDF to get loaded using the following:
if ([indexPath row] == 2)
{
NSString *path = [[NSBundle mainBundle] pathForResource:#"myFirstPdf" ofType:#"pdf"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webViewVC.webView loadRequest:request];
webViewVC.parent = _parent;
[_parent pushViewController:webViewVC];
}
The webViewVC itself I allocate using an initWithNib which has the UIWebView - nothing fancy there, simply a UIWebView with a IBOutlet.
Any ideas?
I think you should try 2 things:
(1) First, try loading the PDF from the web view controller. This is really the standard way to do this, rather than doing a load request for a web view that is not even on screen yet. All outlets are guaranteed to be loaded only in viewDidLoad of the controller.
(2) Second, try making use of the UIWebViewDelegate. For example, you could call setNeedsDisplay on the web view once loading is finished.
My idea : the first time you try the action your "webViewVC" hasn't been loaded yet, so webViewVC.webView is nil
the second time as you have displayed the webViewVC in your first attempt, it has been loaded, so webViewVC.webView isn't nil;
create a property on your webViewVC where you will set your request
and on your webViewVC viewWillAppear method do your [self.webView loadRequest:self.request];
I have a WebView in my app that works fine but very slow to load. Is there a way to actually start loading the web view as soon as the app starts?
Thanks
[EconCalWebView setDelegate:self];
// Do any additional setup after loading the view.
NSURL *myURL = [NSURL URLWithString:#"http://www.forexyard.com/en/calendar.iframe?zone_id=9493"];
NSURLRequest *myRequest = [NSURLRequest requestWithURL:myURL];
[EconCalWebView loadRequest:myRequest];
You can write your code for loading webview in:
applicationDidFinishLaunching method available in AppDelegate Class.
Here you require to load your viewController first and then load webView.
Please find more details at : UIApplicationDelegate
I'm trying to load documents into my app for display and this works if they're stored locally but not from the server. I'm testing with MAMP. Here's my viewDidLoad method:
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *myUrl = [NSURL URLWithString:#"http://localhost:8888/FilesForApp/Docs/MS.doc"];
NSURLRequest *myRequest = [NSURLRequest requestWithURL:myUrl];
[_webView loadRequest:myRequest];
}
Can anyone point tell me if there's something missing from this?
-EDIT-
Forgot to add, it doesn't crash, just shows a plain, white display.
Make sure you can access that doc through your web browser(make sure the doc exists).
Try to add the http:// prefix.
Don't forget to add _webView as subView to your view.
Don't forget to set the _webView's frame.