Iphone 当我们打开UIPickerView时,视图将如何自动滚动?

Iphone 当我们打开UIPickerView时,视图将如何自动滚动?,iphone,ios5,uiscrollview,xcode4.2,uipickerview,Iphone,Ios5,Uiscrollview,Xcode4.2,Uipickerview,我在UIButton点击时打开UIPickerView,我在UIPickerView上调用提交动画,UIPikerView像键盘一样从屏幕底部到中间打开,我想在picker视图显示时向上滚动视图,因为当UIPikerView打开时,我调用UIPickerView的按钮被UIPikerView隐藏。那么,如何在选择器视图打开时自动滚动视图呢?您可以使用此选项向上滚动主视图,向下滚动主视图 - (void)scrollUpView { CGFloat kMoveRatio = 50.0f /

我在UIButton点击时打开UIPickerView,我在UIPickerView上调用提交动画,UIPikerView像键盘一样从屏幕底部到中间打开,我想在picker视图显示时向上滚动视图,因为当UIPikerView打开时,我调用UIPickerView的按钮被UIPikerView隐藏。那么,如何在选择器视图打开时自动滚动视图呢?

您可以使用此选项向上滚动主视图,向下滚动主视图

- (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];
}

您可以使用此选项向上和向下滚动主视图

- (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];
}
使用以下代码:

[UIView animateWithDuration:.5f animations:^{
  CGRect theFrame = myView.frame;
  //Change your frame here
  myView.frame = theFrame;
}];
使用以下代码:

[UIView animateWithDuration:.5f animations:^{
  CGRect theFrame = myView.frame;
  //Change your frame here
  myView.frame = theFrame;
}];

谢谢,如果我还想在调用scrollUpView后向上/向下滚动视图以查看所有按钮(如使用uiscrollview),并且uipickerview仍会打开,我该怎么办?谢谢,如果我还想在调用scrollUpView后向上/向下滚动视图以查看所有按钮(如使用uiscrollview)而且uipickerview仍然打开我该怎么做?