I have a UIActionSheet
containing a picker
and a UIToolbar
. On the UIToolBar there is a done button. However, when I spin Picker
component and before it stops spinning, if I tap Done
button then I'm not getting any value in my UITextfield
. If I tap the Done
button after picker stops spinning animation, then I'm getting the value of selected component
Is there any way to get value of item before stop Animation..?
SOLVE
- (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;
}
and also
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
txtCountry.text = [arrCountry objectAtIndex:row];
countryCode=[arrCountryCode objectAtIndex:row];
}