0

我需要一些有关 nsarrays 和 uipicker 的帮助

我有一个由列 a、b、c、d 和行 m1、m2、m3、m4 组成的数据表,表中的每个单元格都有 2 个值上限和下限

例如,单元格 m3,b 的值为 20 和 25

抱歉,如果这不是很清楚,我想插入一张桌子的图片,但我没有足够的声望点来这样做

无论如何,我只是想在 uipickerview 中表示此数据表,以便组件 0 具有行 m1、m2、m3 等组件 1 具有列 a、b、c、d 等,第 2 列和第 3 列显示上限和下限

我认为这样做需要一个二维数组,但我不知道如何正确创建数据源

任何人都可以请教

非常感谢

4

1 回答 1

1

在此我对几周前提出的问题的解决方案可能对其他知道的人有用?

这在我看来确实加载了

    //integer to hold the current row of component 0, this is set to "0" when the view loads.
component0 = 0;
component1 = 0;

    // get the plist

NSString *path = [[NSBundle mainBundle ] pathForResource:@"mywheelsdata" ofType:@"plist"];

    // Assign the contents of the plist to a NSDictionary for processing
mypickervalues = [[NSDictionary alloc] initWithContentsOfFile:path];

    // Creats an array from the keys which we will then use as labels in the picker.

NSArray *sortArray = [[NSArray alloc] initWithArray:[mypickervalues allKeys]];

wheelone = [[NSArray alloc] initWithArray:[sortArray sortedArrayUsingSelector:@selector(localizedStandardCompare:)]];

[sortArray release];

NSArray *sortArray2 = [[NSArray alloc] initWithArray:[[mypickervalues objectForKey:[wheelone objectAtIndex:component0]]allKeys]]; 

wheeltwo = [[NSArray alloc] initWithArray:[sortArray2 sortedArrayUsingSelector:@selector(localizedStandardCompare:)]];
[sortArray2 release];


    // setup uipicker and assign to myPicker
myPicker = [self setupPicker];

    // Loads the data linked to the appropriate field in the table of data supplied.
wheelthree = [[NSMutableArray alloc] initWithArray:[[mypickervalues objectForKey:[wheelone objectAtIndex:component0]] objectForKey:[wheeltwo objectAtIndex:component1]]];

希望有人可以就上述代码提供建议,但到目前为止它似乎对我来说还可以

于 2011-08-25T05:55:50.853 回答