我在 UIButton 点击时打开 UIPickerView 并且我正在通过这个 UIPickerView 调用 UIPickerView 上的提交动画 UIPikerView 从屏幕底部到屏幕中间像键盘一样打开我想在选择器视图显示时向上滚动视图,因为我调用 UIPickerView 的按钮是隐藏的由 UIPikerView 打开时。So how can i auto scroll the view when picker view is open?
问问题
873 次
2 回答
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];
}
于 2012-06-12T06:02:28.470 回答
0
使用以下代码:
[UIView animateWithDuration:.5f animations:^{
CGRect theFrame = myView.frame;
//Change your frame here
myView.frame = theFrame;
}];
于 2012-06-12T06:10:36.460 回答