iPad app with multiple UIWebViews in the same screen - objective-c

does it hurt performance to have multiple UIWebViews in the same screen? how do I use a busy indicator while the web page is loading and display the fully loaded page once all contents have been downloaded?

Two UIWebViews will take twice the time to render on screen. If this is a problem depends on your app and your content. Just try it.
To implement your busy indicator you could implement a delegate for your WebViews. see UIWebViewDelegate-Protocol

Related

Handling loading efficiently while scrolling on a UICollectionView of Videos

I am currently building an objective c application in xcode that features a full screen horizontally scrolling collection view with cells that take up about 80% of the screen; similar to that of Instagram, Vine, etc. Initially in these cells are video thumbnails that are loaded from a backend source upon the loading of the view.
Since it would be terribly inefficient to load all of these videos at once, I am trying to find a way to only load one video at a time while the user scrolls through the collection view.
The way I am achieving this right now is by using the scrollViewDidEndDecelerating method to calculate whichever cell is in the center of the screen after scrolling, and then beginning to load the video, as well as the scrollViewDidScroll method to stop loading the video. This implementation is shown below:
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
//calculate which cell is in the center
//load video in respective cell
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
//stop loading video
}
As you all can probably see, this generates a lot of ux problems:
The video doesn't start loading until scrolling has stopped
completely
This approach doesn't account for drag gestures to
navigate the Collection View
Once a video has loaded, any drag or
scroll stops loading/playing the video
There are times where no video is loading, between scrolls
I am trying to turn this current approach into a system similar to the Instagram method of loading videos, which is as follows:
A video begins to load as soon as it begins to show up on the screen while the user scrolls
A video stops loading when a different video begins to appear on the screen while the user scrolls.
One video is always being loaded, there is no downtime between loading one video and another
I understand that in order to achieve this functionality, these loading functions will need to be done on a background thread in order to allow for seamless scrolling which I can handle, I just need to know which methods I should be using instead of the ones i'm using now in order to achieve this functionality.
You should make it such that the video uses "lazy loading" to load its contents/thumbnail.
To make it play when cell is at center, use scrollViewDidScroll to detect if the cell is completely showing by method indicated at this answer

progress bar during loading

i wrote an app with different views, the main one is basically a web view that displays a PDF on the web (with a specific url). the problem is that this pdf is a bit big (around 5-10 MB) and it takes a lot to load it. during this loading period the screen remains white. i thought to add a sort of progress bar that appears and disappers automatically, based on the file loading, but i have no idea about how to do this… can someone help me?
(if you have better ideas you are free to tell)
if you are using web view to load the pdf then you can use the webview delegate methods to show the progress bar

UIPageControl lagging on retina devices

I've implemented an iphone app with a page controller following Apple's code example. There are only 3 views on the page controller. The app works fine on normal screens, but when I test it on retina devices, there is a visible lag when scrolling either horizontally or vertically in any of the views. Any ideas of what the problem might be or how can I "debug" this?
The content of 2 of the views is a table view and on the third view I'm using CorePlot. The network is not used while scrolling.
The amount of data loaded and drawn during the scroll makes your device choking. Try to load those views in other thread using gcd and blocks.
I was adding a shadow around the 3 views and that's what was making the scrolling slow.

Can I maintain smooth scrolling when loading HTML into child UIWebView?

I need to show a paginated slideshow of moderately DOM-intensive HTML pages in an iPad application.
All documents are tailored for iPad screen so there is never any scrolling inside UIWebViews.
I decided to put UIWebViews inside UIScrollView for pagination.
It works really well and smooth after all web views have rendered their content.
However, I can't afford waiting for 20, 30 or 50 web views to load before user can scroll: it takes minutes.
I tried to anticipate swipes in scrollViewDidScroll handler and pre-load a few next pages as user keep scrolling.
This worked much better (no performance difference between 10 or 150 web views).
However calling loadHTMLString in scrollViewDidScroll handler causes scrolling to lose it smoothness.
I don't care if it takes a second longer to show a particular UIWebView—all I want is for scrolling to be smooth and available as soon as possible, and to lazily preload UIWebViews on the go.
How do I achieve that?
This is a difficult problem and there is no easy/elegant way to solve it.
One way to speed up the scroll would be to lazy load the pages as you stated in your question. However, in order to ensure smoothness you would have to control when the loading happens.
So say you began by loading the first 5 pages on initial launch. When the user scrolls to page 2 and STOPS, you begin loading page 6. As soon as the user starts scrolling again you pause the loading only to resume when they have stopped on a new page. Pausing the loading in between will help smooth out the scrolling. Also, make sure you release data when possible because it can build up and hinder smooth scrolling down the line.
Another option would be to have the UIWebViews begin loading only as soon as the user stops on the page. So say I scroll to page to, once the scrolling stops I begin to load the HTML. This is not as "pretty" as the first options but it will ensure that the scrolling is smooth.
Another option, this one is a bit out there, is to run through and load all the HTML pages rich text. Leaving out all the DOM intensive stuff. Then grab a screen shot of those semi-loaded page using this method. When the user stops on the page you load it all the way including the DOM intensive stuff. This will let the user feel as thought they are scrolling quick with everything loaded.
Here is a great scrolling class that I have used before.
Here is some code to help with method 3.
Good luck and I hope that this helps!
EDIT:
Here is a great post from the guys at LinkedIn on how they solved webView scrolling problems. It would be worth a read.

How to create animated splash screen not with Images in iOS

I want to know that how one should proceed in building animated splash screen.
I already did the animated splash screen with images but here I want to add custom animation like something is drawn on screen etc.
can anyone guide me through this.
simply you need to present a UIViewController which is hold your animations and dismiss it when your app is ready to launch. but also I think its better to follow apple HIG .. as apple describe you should
Supply a launch image to improve user experience.
Avoid using your launch image as an opportunity to provide:
An “application entry experience,” such as a splash screen An About
window Branding elements, unless they are a static part of your
application’s first screen Because users are likely to switch among
applications frequently, you should make every effort to cut launch
time to a minimum, and you should design a launch image that downplays
the experience rather than drawing attention to it.
Generally, design a launch image that is identical to the first screen
of the application.
Exceptions:
Text. The launch image is static, so any text you display in it will
not be localized.
UI elements that might change. Avoid including elements that might
look different when the application finishes launching, so that users
don’t experience a flash between the launch image and the first
application screen.