1

I am opening UIPickerView on UIButton click and i am calling commit animation on UIPickerView by this UIPikerView opens like a keyboard from bottom to mid of screen i want to scroll up the view when picker view shows because of buttons by which i calling the UIPickerView is hide by UIPikerView when it is open. So how can i auto scroll the view when picker view is open?

iosuser
  • 125
  • 1
  • 3
  • 10

2 Answers2

1

You can use this to scroll the main view up and scroll down main view

- (void)scrollUpView {
    CGFloat kMoveRatio = 50.0f // Change to view the buttons
    [UIView beginAnimations:@"UP" context:nil];
    CGRect aVFrame = self.view.frame;
    [self.view setFrame:CGRectMake(aVFrame.origin.x, aVFrame.origin.y - kMoveRatio, aVFrame.size.width, aVFrame.size.height)];
    [UIView commitAnimations];

}

-(void)scrollDownView
{
    [UIView beginAnimations:@"DOWN" context:nil];
    CGRect aVFrame = self.view.frame;
    [self.view setFrame:CGRectMake(aVFrame.origin.x, 0, aVFrame.size.width, aVFrame.size.height)];
    [UIView commitAnimations];
}
DLende
  • 5,162
  • 1
  • 17
  • 25
  • Thanks and if i also want to scroll the view up/down after calling scrollUpView to see all buttons(like working of uiscrollview) and also uipickerview still opens what should i do for this? – iosuser Jun 12 '12 at 07:07
0

Use below code:

[UIView animateWithDuration:.5f animations:^{
  CGRect theFrame = myView.frame;
  //Change your frame here
  myView.frame = theFrame;
}];
Apurv
  • 17,116
  • 8
  • 51
  • 67