I'm writing a browser application for Mac to match my Windows one. I have a WebView on my window and so far I have a working browser. However, I need to run a method I've written when the WebView finishes loading a page. Is there a way to do this? If not, how can I work around that? Thanks!
You can call your method in the webView:didFinishLoadForFrame: delegate call that is in the WebFrameLoadDelegate.
Related
Is there a quick and easy way to have the app go back to the same screen after I put it in background mode?
I know there are frameworks just for this stuff, but has anyone done it without much sweat?
Thanks
In your app delegate, add a line to the applicationDidenterBackground: method that stores the current page via NSUserDefaults.
Then in the applicationWillEnterForeground: method, load up that saved value and restore the page.
Multitasking should enable this, while a device has enough memory to keep your app open. Otherwise how about using NSUserDefaults to store a string reference to your view?
As of iOS 5.1, there is no quick and easy way.
I am writing an app which is going to be displaying images found on my server in a UIImageView.
I need something that will asynchronously download the image and cache it while putting it in the UIImageView.
The download also needs to be able to be cancelled when I press a button.
Can anyone point me in the direction of something that can do this?
In the old times the framework for that was ASIHTTPRequest but is an abandoned project now. This https://github.com/AFNetworking/AFNetworking seems to be popular now.
Use the performSelectorInBackground:withObject: - method from NSObject ;)
Advise: The updating of the view must run on the main thread!
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/nsobject_Class/Reference/Reference.html
I found a bug in iOS 5.
When you are using a UIWebView and access some sites, you create your history links, look like any other browser.
If you like to use a navegation bar, can use the functions goBack and goForward
In iOS 4.3 and below, when you call this function the program call the delegate function
webView:shouldStartLoadWithRequest:navigationType:
But in iOS 5.0 this can happens or not. If the site is in cache, it not call this function. I saw this happens in only 1 level (1 click in goBack or 1 to goFoward), in the second click it pass in the function.
Why they change it???? Even it is in cache, the program have to ask for me.. Now how solve this: I am trying make a stack with the browser history and I check the url. But i am having problem ;(
There are no other way?
I can't see the browser history? I have to create my ow list?
I can't clean the cache to force it pass in the function?
Any sugest?
It's not a bug, if there is enough available RAM on the device then it will keep some of the pages in memory, therefore they are not being "loaded" again when you go back.
You should create your own goBack: and goForward: actions on your own controller, and link the goBack/goForward buttons to them:
- (IBAction)goBack:(id)sender
{
[self doStuff];
[self.webView goBack:sender];
}
I'm working with a webview within a window of a Cocoa application. I would like to retrieve some values using stringByEvaluatingJavaScriptFromString on the webview and save them before the application shuts down. I tried using the applicationWillTerminate but by the time I reach this method, it is too late. I was wondering if there's something built into webview that I've missed or if anyone has an elegant solution to share.
If you want to save this information, why are you waiting until the app is about to terminate?
Iam doing an ipad app using splitview controller.Iam getting images from webservice by using custom tableview in rootview.But one problem is when loading the images suddenly struck the simulator. so, What i have to do?
My guess is that you aren't fetching the images asynchronously, although it is a bit of a wild guess as the question could do with re-phrasing.
IF that is the issue ...
If you are using the SYNCHRONOUS method NSURLConnection sendSynchronousRequest:returningResponse:error: you need to wrap it in a NSOperation so it doesn't block the main UI thread.
More usually you would use the asynchronous methods of NSURLConnection.
Better still, consider the third party library ASIHTTPRequest which can do all this for you and more.