progress bar during loading - cocoa-touch

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

Related

Cocoa Webview - Camouflage webview as native control

OK, I'm doing some experiments with WebView-based native OSX apps, and I'm wondering:
Which are the necessary steps in order to fully camouflage it? (So, that the user - ok, a non-technical user, actually) cannot possibly understand it's a webview.
How can we eliminate the right-click menu (including the "Reload" item)?
Last but not least:
If the actual webpage content is loaded on startup (in awakeFromNib), even for a simple webpage, it takes 1-or-2 seconds before the actual content shows up. During this time, a white/empty background shows where the webview/page should be. What could I do about that? Perhaps a "loading" indicator?
Any help will be appreciated! :-)
To eliminate the right click menu implement the webView(_:contextMenuItemsForElement:defaultMenuItems:) method of WebUIDelegate protocol.

cocos2d mac application how to add splash screen when launching (Default.png)

i am migrating my iOS app onto mac. the loading time is a bit long (around 5 seconds) thus i need a splash loading screen (Just like Default.png image for iOS) but the project made from cocos2d template just shows a white screen. not sure about other apps. so is there anyway to set it?
I know that the screen size is not fixed on a mac app. but i have set a default size. and use auto scale in case of full screen mode.
EDIT:
I have tried a light weight loading scene as well but failed since the MainScene itself is light weight as well. I think the major loading time is due to the cocos2d environment set up.
In OS X a window appears when the application launches, it's not designed to use splash screens.You might want to reconsider that choice.
But if the window is still to slow to load or to display its contents, you can still do that but manually, it isn't easy like in iOS.You need to display another view inside the window until it loads.
EDIT
A little more of context: for example you can set in your xib file an image view containing the image do display.
Then you make start another thread that loads all the content that you need.After this, run a selector on the main thread that updates the window.
Based on my tests in Cocos2d 1.0.1 & 2.0 the basic Cocos2d OS X app launches really quickly.
This makes it seem pretty likely that it's something about your first scene that is taking a long time to load, or something else. Instruments can help you gather information about what your app is doing.
I suggest you make an initial lightweight cocos2d scene that will load quickly at startup and then load your second scene and transition to it. Ideally the loading of the assets for your second scene would be asynchronous (at least the ones that are slow). There are numerous blog posts on how to do this. (search for "cocos2d asynchronous loading" and you'll find many, such as this one: How to preload your game assets in a loading scene, though something more recent might be preferable).

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.

iOS app launch takes too long to display

Working on first app, have most of the programming done but app is taking too long at launch to display first tableview on tabbar. It takes 8-10 seconds on launch to display. Looking for help on tracking down what code is taking so long, etc. Here is the general app setup: tabbar with 5 tabs including navigation bars, mix of tableviews with detail views and scrollviews. The data for the tableviews is from multiple json feed from a remote web server. In the appdelegate.m I'm setting up the full tab/navigation bars. I get the json data feeds in each individual view controllers that setup on the tabbar. I've used the Profiler but don't know what I'm looking for and where. What is loaded on launch? Any advice on general setup of app that could be causing the delay? Does it load all views associated on the tabbar? Thanks in advance for any help.
Run your program through instruments. Always. All the time. It will tell you most of the problems.
That said, you probably need to delegate your startup tasks to background threads, and update the UI as data comes available.
Use NSOperation, GCD, and related technologies for executing your background tasks.

iPad app with multiple UIWebViews in the same screen

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