gpt4 book ai didi

iphone - 如果我在选择器旋转时使用完成按钮关闭 UIPickerview 的操作表,则获取空值

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

我有一个 UIActionSheet包含 pickerUIToolbar .在 UIToolBar 上有一个完成按钮。然而,当我旋转 Picker如果我点击 Done,则组件在它停止旋转之前按钮,那么我的 UITextfield 中没有任何值(value).如果我点击 Done选择器停止旋转动画后的按钮,然后我得到所选组件的值

有没有办法在停止动画之前获得项目的值(value)..?

解决

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *lbl = (UILabel *)view;

// Reuse the label if possible...
if ((lbl == nil) || ([lbl class] != [UILabel class])) {
CGRect frame = CGRectMake(0.0, 10.0, 250, 50);
lbl = [[[UILabel alloc] initWithFrame:frame] autorelease];
}
if (component == 0) {

lbl.textColor = [UIColor blackColor];
lbl.textAlignment=UITextAlignmentLeft;
lbl.backgroundColor = [UIColor clearColor];



lbl.text = [arrCountry objectAtIndex:row];
lbl.font=[UIFont boldSystemFontOfSize:14];
NSInteger clm1 = [pickerView2 selectedRowInComponent:component];


txtCountry.text = [arrCountry objectAtIndex:clm1];
countryCode=[arrCountryCode objectAtIndex:clm1];
}

return lbl;
}

并且
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{

txtCountry.text = [arrCountry objectAtIndex:row];
countryCode=[arrCountryCode objectAtIndex:row];
}

最佳答案

我不认为你可以交配。 UIPicker 仅在微调器停止时调用 didselectrow ,否则它会卡在先前选择的行上。在你的情况下的第一个。

最接近使用 uipicker 获得功能的是这个委托(delegate)方法:

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view

您必须查看屏幕上的 View 及其与中心的偏移量。除此之外,您可以实现自己的 ScrollView 并拥有一个 uipicker 覆盖,但这涉及大量工作。

或者!您可以告诉您的用户以正确的方式使用 uipicker,哈哈。

阻止用户按下保存的另一种方法是检测 uipicker 是否正在旋转。我找到了 this to help你。

关于iphone - 如果我在选择器旋转时使用完成按钮关闭 UIPickerview 的操作表,则获取空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13284703/

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