数値を含む 3 つのコンポーネントを持つ UIPicker があります。これにより、ユーザーは hh:mm:ss 形式で時間を設定できます。最初のコンポーネントから時間を選択すると、UITextField は 10:(null):(null) のようになります。ユーザーが適切な mm と ss を選択すると、(null) を削除できます。しかし、ユーザーが 10 時間を入力したいだけの場合は、ユーザーがピッカー コンポーネントを物理的に移動することなく、他の値を (null) ではなく 00 にします。
誰でもこれについて何か考えがありますか?
以下のいくつかのコード、この質問は timePicker に関連しています。
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
if([pickerView isEqual: routePicker])
{
route.text = [[routeArray objectAtIndex:0] valueForKey:@"route_name"];
return [[routeArray objectAtIndex:row] valueForKey:@"route_name"];
}
else if([pickerView isEqual: activityPicker])
{
activity.text = [activityArray objectAtIndex:0];
return [activityArray objectAtIndex:row];
}
else if([pickerView isEqual: intensityPicker])
{
if ([intensityArray objectAtIndex:row]==@"Low")
numberIntensity=2;
else if ([intensityArray objectAtIndex:row]==@"Low-Medium")
numberIntensity=3.5;
else if ([intensityArray objectAtIndex:row]==@"Medium")
numberIntensity=5;
else if ([intensityArray objectAtIndex:row]==@"Medium-High")
numberIntensity=6.5;
else if ([intensityArray objectAtIndex:row]==@"High")
numberIntensity=8;
else numberIntensity=0;
intensity.text = [intensityArray objectAtIndex:0];
return [intensityArray objectAtIndex:row];
}
else if([pickerView isEqual: timePicker])
{
switch (component)
{
case 0:
return [hourArray objectAtIndex:row];
break;
case 1:
return [minuteArray objectAtIndex:row];
break;
case 2:
return [secondArray objectAtIndex:row];
break;
default:
return 0;
break;
}
}
else if([pickerView isEqual: distancePicker])
{
switch (component)
{
case 0:
return [distance1Array objectAtIndex:row];
break;
case 1:
return [distance2Array objectAtIndex:row];
break;
default:
return 0;
break;
}
}
else
{
return 0;
}
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if([pickerView isEqual: routePicker])
{
route.text = [[routeArray objectAtIndex:row] valueForKey:@"route_name"];
}
else if([pickerView isEqual: timePicker])
{
if (component == 0)
{
selectedHour = [hourArray objectAtIndex:row];
}
else if (component == 1)
{
selectedMinute = [minuteArray objectAtIndex:row];
}
else if (component == 2)
{
selectedSecond = [secondArray objectAtIndex:row];
}
time.text = [NSString stringWithFormat:@"%@:%@:%@", selectedHour, selectedMinute, selectedSecond];
}
else if([pickerView isEqual: distancePicker])
{
if (component == 0)
{
selectedDistance1 = [distance1Array objectAtIndex:row];
}
else if (component == 1)
{
selectedDistance2 = [minuteArray objectAtIndex:row];
}
distance.text = [NSString stringWithFormat:@"%@.%@", selectedDistance1, selectedDistance2];
}
else if([pickerView isEqual: activityPicker])
{
activity.text = [activityArray objectAtIndex:row];
}
else if([pickerView isEqual: intensityPicker])
{
intensity.text = [intensityArray objectAtIndex:row];
}
}