views:

159

answers:

1

I have a very simple app created with the Utility Application project template on XCode. My MainView has two UIPickerView components and two buttons. The FlipSideView has another UIPickerView.

The pickers on the main view each have 4 segments and each segment has 8 rows. The picker on the flip side has just 1 segment with 8 rows. All rows on all pickers are just text.

With just this setup, pressing the button to flip the view back and forth displays a noticeable delay before the animation actually starts, and then the animation actually seems to go faster than what it should, like it's trying to make up for the lost time.

I removed the pickers in interface builder and loaded the app on the phone and the animation now seems natural. I also tried just one picker (the flipside one) and things still seem normal. So my current theory is that the number of objects involved in the main view is the cause. The thing is that I don't think it's that many (4 x 8 x 2 = 64), but I could be completely wrong. This is pretty much my first app so maybe I'm just doing something grossly wrong, or maybe the phone is has a lot more limited processing than I thought.

I am thinking of creating the picker views with pickerView:viewForRow:forComponent:reusingView: to see if this hopefully performs better, but I'm not sure if this is just a waste of time.

Any suggestions?

Thanks Ruy

P.S.: Testing on a 3G phone on 3.1.2

A: 

The number of rows and components has little to do with the performance of the picker view itself. Picker views work like tables, they don't actually have the number of components and rows in memory. Instead, they swap out and reuse the same handful of views displayed on the screen at any one time. So, if you have 4 components that each display 5 rows at a time, the picker view never holds more than 20 views even if you have hundreds of logical rows in each component.

Therefore, the number of logical elements in the picker view's datasource is irrelevant to its visual performance.

I'm not exactly sure what you are seeing with the picker views and the transition but its most likely a result of bog down somewhere in the your custom code that loads and configure the picker view. I would set breakpoints/logs to see where it is spending its time during the transition.

TechZen
There's really not much going on to set up the flipside view. On the main view controller action for when the button is pressed there is:- (IBAction)showInfo { FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil]; controller.delegate = self; controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:controller animated:YES]; [controller release];}And then there is nothing else on the Flipside viewDidLoad other than setting the background color.
Ruy Diaz