gpt4 book ai didi

ios - 即使在 ios 中滚动后也将 UIPickerView 的位置设置在底部

转载 作者:行者123 更新时间:2023-12-01 19:00:15 26 4
gpt4 key购买 nike

我正在尝试显示 UIPickerView点击UITextField .我用一个简单的方法来显示picker如下:

-(void) showPickerView {

[self.view resignFirstResponder];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.50];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
if(iOSDeviceScreenSize.height == 480){

CGRect frame = self.picker.frame;
frame.origin.y = 270;
self.picker.frame = frame;
frame = self.toolBar.frame;
frame.origin.y = 226.0;
self.toolBar.frame = frame;

} else if(iOSDeviceScreenSize.height == 568){

CGRect frame = self.picker.frame;
frame.origin.y = 239.0;
self.picker.frame = frame;
frame = self.toolBar.frame;
frame.origin.y = 195.0;
self.toolBar.frame = frame;

}

[UIView commitAnimations];

}

如果我没有向下滚动,它会很好用。但是当我向下滚动时,我的 picker放置在 showPickerView 中提到的固定位置方法。现在我该如何管理我的 picker每次都出现在底部。

最佳答案

解决方案一:

将您的选择器 View 添加到您的窗口。

方案二:

实现 ScrollView 委托(delegate)并不断调整框架。

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{


CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
if(iOSDeviceScreenSize.height == 480){

CGRect frame = self.picker.frame;
frame.origin.y = 270;
self.picker.frame = frame;
frame = self.toolBar.frame;
frame.origin.y = 226.0;
self.toolBar.frame = frame;

} else if(iOSDeviceScreenSize.height == 568){

CGRect frame = self.picker.frame;
frame.origin.y = 239.0;
self.picker.frame = frame;
frame = self.toolBar.frame;
frame.origin.y = 195.0;
self.toolBar.frame = frame;

}



}

关于ios - 即使在 ios 中滚动后也将 UIPickerView 的位置设置在底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23356635/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com