views:

229

answers:

2

I have a UITabBarController which is switching between tabs just fine. The only issue I have is that sometimes it takes up to 3 seconds to respond (call didSelectViewController).

This only occurs when I am switching between pages with quite a few elements, UIViews and UILabels and such. It is instant to respond when it doesn't have any views to add and remove.

I think that it should call didSelectViewController before doing anything else on receiving a touch, but this does not seem to be the case. Does anyone have any suggestions as to how I can speed up my app?

Thanks

A: 

The time you are expiriencing could be from the new views loading, if your pre load your views or keep them in memory once you already loaded them then I think switchign between them should not take that long of time...

Daniel
A: 

I expect your app is taking a long time to render the view. I suggest stepping through the viewWillAppear: method to see if you are running a slow query or doing something else that takes a lot of time when the view is shown. If so, you might be able to use a cache or show a placeholder page while that is happening. If the app is slow because you really do have so many UIViews, think about using a custom-rendered view instead, or a UITableView and only loading the sub views as they are needed.

In iPhone OS 3.0 has tabBarController:shouldSelectViewController: which gets called after the touch, but before the tab is actually selected.

Will Harris
Thanks for the response. On receiving a tab bar touch, it will immediately break in viewController->viewWillAppear, but on continue will sometimes take a couple of seconds to progress to tabBarController->didSelectViewController, after which a continue will immediately show the tab bar item as being selected. I am not doing anything in viewWill/Did/Appear/Disappear other than calling [super <foo>]. Whatever happens between these two points is causing a significant delay. I am only drawing what is onscreen, so it isn't a huge amount... a few views, labels, images.
Sam
Sorry, having posted that I realised I am actually doing a significant amount of work between viewWillAppear and didSelectViewController! Oops
Sam