【问题标题】:How will the view be auto scroll when we open UIPickerView?当我们打开 UIPickerView 时,视图将如何自动滚动?
【发布时间】:2012-06-12 05:55:58
【问题描述】:

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

【问题讨论】:

    标签: iphone ios5 uiscrollview xcode4.2 uipickerview


    【解决方案1】:

    您可以使用它来向上滚动主视图并向下滚动主视图

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

    【讨论】:

    • 谢谢,如果我还想在调用 scrollUpView 后向上/向下滚动视图以查看所有按钮(如 uiscrollview 的工作)并且 uipickerview 仍然打开,我该怎么办?
    【解决方案2】:

    使用下面的代码:

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

    【讨论】:

      猜你喜欢
      • 2017-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-28
      • 1970-01-01
      相关资源
      最近更新 更多