Loading images from to differenet base resources to the webview - objective-c

I am implementing a WebView in which I need to use some images. For this, I use the images under the ressources folder and call
[myWebView loadHTMLString:returnString baseURL:[[NSBundle mainBundle] resourceURL]];
It is working fine. In the same time I need to use some external images coming from the server in the same WebView. For this I need to change the baseURL of the target server but I don't know how to handle these two.
How to handle both images, from local and external server in one HTML?

If you use full URLs (i.e. http://www.exmaple.com/myimage.png) for the images coming from the server, they won't be affected by the baseURL parameter, which is only used for resolving relative (partial) URLs.

I think you can create two instance of UIView class and add the UIWebView in both the views.
In the first webview show the image from the resource and in the other webview show the image from the server.
Just give it a try see if this works.

Related

How to check if the remote image changes? (Android caches images indefinitely)

I'm losing my mind trying to get this to work.
So, it seems that, in React Native, Android will cache the image of a certain URL forever. If I change the image at that URL, it will not change in the app for Android, but iOS handles it just fine.
I know about the trick of just adding
`?time=${Date.now()}`
to the end of the uri specified in source={{ uri }}
However, that will fetch a new image every time, which technically works, but then the user has to wait for the image to load every time. I could add an ActivityIndicator placeholder while the image loads, but if I could properly cache the image then that ActivityIndicator wouldn't be shown nearly as often, making for better UX.
I would like to know if there's a way to check if the remote image has changed, within the constraints of Expo SDK 33 (no react-native link). I can handle the cache busting just fine if there is such a method, it would just require incrementing a persistently saved integer whenever a change is detected, and appending that to the uri.
Maybe a different approach is necessary.
I fixed this issue in the backend. If you have access to the backend, that's great!
What I did was create an API that would take in the path to the image that I wanted, and it redirected to that image, with ?lastUpdated=<modified> appended to the URL, where <modified> is the time at which that file was last modified. This way, it automatically cache busts the image whenever the image is changed!

Play lock screen slideshow from local images (Windows 8)

I'm trying to play lock screen slideshow from images stored in local folder. All ways which I found didn't help me. There're four methods in LockScreen class from Windows.System.UserProfile namespace and only one allow you to play slideshow(from images which you want). It's:
public static IAsyncOperation<SetImageFeedResult> RequestSetImageFeedAsync(
Uri syndicationFeedUri
)
But 'Uri' parameter must be the external URI of the RSS image feed. That's why I can't use it. Could somebody help me, how o do this?
Actually you can use Uri for local paths. You can find more info here.

How can I add binary image to photo gallery using objective-c

I am creating app to display image from web services on iPad
I use FGallery to create photo gallery on my app and I retrieve binary image form web services and convert it to UIImage.
How can I add images to FGallery?
I am hoping that someone out there might have a solution that can perform this task, or if anyone could point me in the right direction, I would really appreciate it!
FGallery is current written to load images from the application bundle or web server via URL. Because you cannot change the application bundle at run-time, you will need to change FGallery to read images from <Application_Home>/Documents/ folder. Once that is accomplished, you will then save your new UIImage to the application documents folder and update the NSArray *localImages in the RootViewController.

How can I download files from UIWebView using ASIHTTPRequest?

I want to create a section of my app where you can download the current webpage showing in the UIWebView and then save it to a UITableView and when you tap on the filename in the UITableView, it will load the local file in the UIWebView to allow offline browsing.
How can I do this with http://allseeing-i.com/ASIHTTPRequest? I've taken a look and all the code looks very daunting for a beginner! Is there an alternative method? Is this the best method?
Thank you
ASIWebPageRequest is the answer. It's a class included with ASIHTTPRequest that makes it easy to download whole pages, with all their associated dependencies.
You'd probably want to create a custom cache to store your downloaded webpages in, and then load them out of that cache when requested by the user.

iphone app UIWebView cache data

I need a UIWebView to show a html page. if internet is not available it will show the last downloaded version. if has internet then it downloads the most current version and replaces and shows the version just downloaded. how can I do this? Thanks
You could implement you webViews delegate webViewDidFinishLoad: method to grab the request and load it again. Since it was just finished loading, we can assume that it is cached and load it with synchronous networking. Store the result. When network is unavailable load that result into the webView using loadData:MIMEType:textEncodingName:baseURL:. When network comes available agin just call loadRequest: to refresh.
Another option is to use stringByEvaluatingJavaScriptFromString: with a javascript around:
document.getElementsByTagName('html')[0].outerHTML;
and inserting the content with loadHTMLString:baseURL:
But these two only work for pure HTML without images, sounds, etc.
A third option would be to use the NSURLRequestReturnCacheDataDontLoad when network is not available. see NSURLRequest
You migth also have a look at the NSURLCache