How to maintain sessions in a UIwebview in iPhone - objective-c

I have a UIWebview. Let's say I open google in that view and then I press the back button and come back to Webview page again. Is it possible to see google (already opened) instead of loading that page again?

Yes indeed, it is called caching. It basically saves the page in memory so that it can be called later without loading. The only major problem is that if your "cache" (save) a page, if the page is updated on the internet it will not be updated in your app until the page is refreshed and loaded.
There is a lot of information on caching for iOS, just search on the Internet. A helpful link I found is this Stackoverflow question which shows you how to cache content.

Related

Ionic load screen at the same time

I have Ionic app that communicates with Laravel API server side. Thing that bothers me is that elements like buttons and pre-defined text show first, and then after a few milliseconds resources from API load.
I would like the whole page to have that same millisecond pause so that all resources load at the same time, because for instance, my POST call breaks if I click the button to place an order before the server resources are shown on screen.
I have no idea how to google that nor what code part would be useful to paste here, so if anyone had simmilar problem...

Apple's latest (2015) 'link to app store' directive causes unwanted Safari behaviour

I want to add a link from my app to another of my apps on the appstore.
Question How to link to apps on the app store showed that the itunes.apple.com link was,until recently, the normal way to go. I've tried this and everything is fine. The problem begins when I disgard this and use Apple's new recommendation of using appstore.com. I use the following line of code:
[UIApplication sharedApplication] openURL:[NSURL URLWithString:#http://appstore.com/myappname"]];
The first time I call this from my app it works well. You see it jump through Safari and move onto the appstore where it displays my app.
At this point if you look back into Safari you will notice a new blank tab labelled Favourites has been created.
If I go back to my app and perform the same action to link to the appstore again I'm prompted with one of the two popup boxes:
"Open this page in "App Store"? [Cancel] or [Open].
or
"Cannot Open Page. Safari cannot open the page because the address is invalid" [OK]
I've found that manually deleting the blank tab in Safari will allow the link to work properly but this behaviour isn't what I want my users to see- and I wouldn't be expecting them to delete the blank tabs from Safari.
Any advice on stopping this behaviour whilst following Apple's new rules greatly appreciated.
A simple and clean solution is to present an instance of SKStoreProductViewController inside your app (modally) to display information on the products you are interested in. The user can interact with it as a small view on the App Store and you can simply dismiss it when done.

In any web site, the image always downloaded in the background, right?

Just to confirm, the image always downloaded in another thread which is different with the page text loading thread??
I put in my page, refer to a image on internet, the all text always show up firstly.
What do you think?
I think that html file contains all the prose and refers to pictures, so in whatever threads you do that you first download the text. Whether it's rendered before pictures are downloaded is up to UA and they may or may not be the same in this respect.
Depends on the Browser and the website. In most cases the Browser loads the "main html" where there are references to the Pics and other things.
If the Website loads most of the text-content via AJAX it could be kind of the other way round.
.. but in most cases you are right

UIWebView disable location prompt

Is it possible to disable the location prompt (or auto decline/accept it) that pops up when you visit certain websites that ask for locations? I am not using a MKMapView because my app will be not be just viewing maps (it just may visit websites that might have maps on it).
I'm guessing since the prompt is not being controlled by my app, but by the iOS system, I probably will not be able to auto decline/accept the dialog.
As far as disabling the prompt from within an IOS app while loading a UIWebView, it is possible.
You will need to intercept the html before it gets loaded into the UIWebView then find which part of it triggers the GPS/Location Prompt. Once you found it, you simply remove it from the html then feed the html into the UIWebView thus 'disabling' the prompt. However, as a result, the webpage will be missing that element.
No, it's not possible to do that. Not with UIWebView, not with any iOS browser.
I know no way to prevent the prompt, I hope it will be implemented as a property of the UIWebView.
The dialog is not there for the safety of the user, when it comes to UIWebViews. The app containing the view has already asked for locations access, and it can be enabled and disabled on settings. To ask for location access both from the app and from the web view, I would regard as a bug.

UIWebview javascript leak?

I've posted about this before but have been struggling to come up with a solution.
Basically I have a HTML5/jQuery app within my iPad app. Every time I load an image into the UIWebView (HTML App) the overall allocations in the profiler increases by about 2MB each time. This sounds about right because the image is approx 2MB's. I am using the data notation in the tag to load a Base64 image.
i.e.
When I load a certain number of images (page turns) the app will crash.
The app is an ebook viewer, so when I turn to a new (not previously loaded in current session) the allocations increase. But, if I turn back to a previiously loaded page the allocations don't increase and the page loads quicker than a new one. Every page turn sends a request to the database so i'm beginning to think the leak isn't in the iOS and that it could be in the HTML5 app.
Any ideas on this? I guess there could just as easily be a leak in the HTML app as there could be in iOS. How do I go about debugging this?
Any ideas greatly appreciated.
Thanks
HTTP and WebKit likes to keep a local copy of resources, just in case you will need it again. This may be what you encounter.
Check the answers to this question: Is it possible to prevent an NSURLRequest from caching data or remove cached data following a request?
This was die an unfixable issue with iOS 4.
Issue resolved itself after upgrading to iOS5.