Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如果为0,则应修剪pickerview及其选定值_Objective C_Uipickerview - Fatal编程技术网

Objective c 如果为0,则应修剪pickerview及其选定值

Objective c 如果为0,则应修剪pickerview及其选定值,objective-c,uipickerview,Objective C,Uipickerview,我在一些视图中有一个pickerview,其中有6个组件,所有组件都有相同的数组,数组是0到9个整数。现在我必须从每个组件中选择一行。和选定值打印在文本字段上。它正在发生,但现在的问题是,如果用户选择000130(即示例),那么在文本字段上,它应该写为130。我怎么能做到呢 - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {

我在一些视图中有一个pickerview,其中有6个组件,所有组件都有相同的数组,数组是0到9个整数。现在我必须从每个组件中选择一行。和选定值打印在文本字段上。它正在发生,但现在的问题是,如果用户选择000130(即示例),那么在文本字段上,它应该写为130。我怎么能做到呢

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



    str_final = [NSString stringWithFormat:@"%@%@%@%@%@%@",
                           [orderValueArr objectAtIndex:[pickerView selectedRowInComponent:0]],
                           [orderValueArr objectAtIndex:[pickerView selectedRowInComponent:1]],
                           [orderValueArr objectAtIndex:[pickerView selectedRowInComponent:2]],
                           [orderValueArr objectAtIndex:[pickerView selectedRowInComponent:3]],
                           [orderValueArr objectAtIndex:[pickerView selectedRowInComponent:4]],
                           [orderValueArr objectAtIndex:[pickerView selectedRowInComponent:5]]];
 NSString *trimMe = str_final;
trimMe = [trimMe stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSLog(@"trime me %@", trimMe);
    orderValueText.text = trimMe;


//}

}
但这不是我想要的回应

请大家帮帮我


提前感谢

只需将字符串值转换为整数值即可。您将删除修剪过的零。使用此代码

    NSString *trimMe = @"000130"; 
    trimMe = [NSString stringWithFormat:@"%d",[trimMe intValue]];
    NSLog(@"%@",trimMe);

如果你对这个答案感到满意,就意味着接受这个答案。。