I have the following two animations that I'd like to be made smoother, any suggestions would be very much appreciated:
The issue is that the animation is jerky. Some of the cells that will be hidden once the picker is fully expanded seem to hide prematurely.
(BTW, my y values don't add up to 480 because there's a navigation bar at the top of the screen.)
Edit:
Also, when I hit the back button in my navigation controller, the picker suddenly flies up from the bottom and off to the top left of the screen.
Ideally this would work just like the keyboard... (IE, the keyboard slides off the side with the view when you hit the back button. I'd like the picker to do that too.)
Code:
- (void) selectClass
{
if (classPicker == nil)
{
classPicker = [[UIPickerView alloc] initWithFrame:CGRectZero];
classPicker.frame = CGRectMake( 0.0, 416.0, 320.0, 216.0);
[self.tableView.superview addSubview:classPicker];
classPicker.showsSelectionIndicator = YES;
classPicker.delegate = self;
classPicker.dataSource = self;
[classPicker release];
}
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: 0.3];
classPicker.frame = CGRectMake( 0.0, 200.0, 320.0, 216.0);
self.tableView.frame = CGRectMake( 0.0, 0.0, 320.0, 200.0);
[UIView commitAnimations];
[self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemDone target:self action: @selector(doneButton)] animated:YES];
}
- (void) doneButton
{
[self.navigationItem setRightBarButtonItem:nil animated:YES];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: 0.3];
if (classPicker != nil)
{
self.tableView.frame = CGRectMake( 0.0, 0.0, 320.0, 416.0);
classPicker.frame = CGRectMake( 0.0, 416.0, 320.0, 216.0);
}
[UIView commitAnimations];
}
The issue is that the animation is jerky. Some of the cells that will be hidden once the picker is fully expanded seem to hide prematurely.
(BTW, my y values don't add up to 480 because there's a navigation bar at the top of the screen.)
Edit:
Also, when I hit the back button in my navigation controller, the picker suddenly flies up from the bottom and off to the top left of the screen.
Ideally this would work just like the keyboard... (IE, the keyboard slides off the side with the view when you hit the back button. I'd like the picker to do that too.)