我有一个UIActionSheet
包含 apicker
和 a UIToolbar
。在 UIToolBar 上有一个完成按钮。但是,当我旋转Picker
组件并在它停止旋转之前,如果我点击Done
按钮,那么我的UITextfield
. 如果我Done
在选择器停止旋转动画后点击按钮,那么我将获得所选组件的值
有没有办法在停止动画之前获得项目的价值..?
解决
- (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];
}