简体   繁体   English

我的UITableView的第一项不起作用

[英]my UITableView's first item doesn't work

I am having some weird problem with my program!! 我的程序遇到一些奇怪的问题! I have created a nested mutable array, which consists of 4mutable arrays, each containing a string and 4 other array, each again containing a two strings. 我创建了一个嵌套的可变数组,它由4个可变数组组成,每个可变数组包含一个字符串和另外4个数组,每个数组又包含两个字符串。 here's the log I received when I passed my array through NSLog: 这是我通过NSLog传递数组时收到的日志:

I have then used 3 tableview controllers to somehow create a navigation through these arrays, as with the first tableview controller, I load the second one depending on which item of the original array was selected, and so on and so forth. 然后,我使用了3个tableview控制器以某种方式在这些数组中创建了导航,就像第一个tableview控制器一样,我根据选择了原始数组的哪个项来加载第二个tableview控制器,依此类推。

everything works perfectly for all the arrays, except the first top level one (the first array containing 一切对所有数组都适用,除了第一个顶层(第一个包含

I use objectAtIndex and have tempProjectNumber, which holds the selected index.row of the first tableview controller for selecting the project. 我使用objectAtIndex并具有tempProjectNumber,该属性保存第一个用于选择项目的tableview控制器的选定index.row。 however, when my second tableviewcontroller loads the cell.textlabel.text, I receive a sigbart error: 但是,当我的第二个tableviewcontroller加载cell.textlabel.text时,我收到了sigbart错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI isEqualToString:]: unrecognized selector sent to instance 0x8987c80' 由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'-[__ NSArrayI isEqualToString:]:无法识别的选择器已发送到实例0x8987c80'

I managed to find out the class of the item I try to access when loading the text for cell.textlabel, and it says it's a >__NSCFConstantString. 我设法找到了为cell.textlabel加载文本时尝试访问的项目的类,它说这是一个> __ NSCFConstantString。

this is the complete log: 这是完整的日志:

>2011-11-13 01:36:42.031 iCodeMobile[4763:15203] indexpath.row: 1 projectnumber:0 
>2011-11-13 01:36:42.032 iCodeMobile[4763:15203] array: __NSCFConstantString 
>2011-11-13 01:36:42.033 iCodeMobile[4763:15203] indexpath.row: 2 projectnumber:0 
>2011-11-13 01:36:42.033 iCodeMobile[4763:15203] array: __NSCFConstantString   
>2011-11-13 01:36:42.034 iCodeMobile[4763:15203] indexpath.row: 3 projectnumber:0 
>2011-11-13 01:36:42.035 iCodeMobile[4763:15203] array: __NSCFConstantString 
>2011-11-13 01:36:42.036 iCodeMobile[4763:15203] indexpath.row: 4 projectnumber:0 
>2011-11-13 01:36:42.036 iCodeMobile[4763:15203] array: __NSArrayI>

the index path.row recordings are the row of the table for second view controller, and the project number is the second highest level array, with first item of testproject1. index path.row记录是第二个视图控制器的表的行,项目号是第二个最高级别的数组,其中第一个项目是testproject1。 and the array loggings are the class of the item I'm trying to access. 和数组日志记录是我要访问的项目的类。 as you can see the last one is the NSArrayI, but I'm not using anything like that, as you can see from the mapping of my array earlier. 如您所见,最后一个是NSArrayI,但我没有使用类似的东西,正如您从前面的数组映射中可以看到的那样。

interestingly, if I use debugging mode and step into each line, after all the cell rows have been loaded with the texts, which are correct, I get this error: 有趣的是,如果我使用调试模式并进入每一行,则在所有单元格行都加载了正确的文本之后,我会收到此错误:

[CALayer objectAtIndex:]: unrecognized selector sent to instance 0x7f51f40 I'm not using any layers, and I don't even know what to do!!! [CALayer objectAtIndex:]:无法识别的选择器发送到实例0x7f51f40我不使用任何层,我什至不知道该怎么做!

Please help as I'm dealing with this problem for almost a month. 请帮忙,因为我正在处理这个问题将近一个月。 I was using uipickerview and the same thing happened, the same first item problem and the same SIGBART error!!! 我正在使用uipickerview,发生了相同的事情,相同的第一项问题和相同的SIGBART错误!

Thanks. 谢谢。

UPDATE @Mundi: 更新@Mundi:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
   {
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault    reuseIdentifier:CellIdentifier] autorelease];
    }
    if (indexPath.row==0)
    {
        cell.textLabel.text = @"Please Select A folder";
    }else
    {
        NSLog(@"indexpath.row: %u projectnumber:%u",indexPath.row,shared.tempProjectNumber);
        id object = [[shared.fileNameContainer objectAtIndex:shared.tempProjectNumber]    objectAtIndex:indexPath.row];
        if ([object isKindOfClass:[NSString class]]){
            NSLog(@"String: %@",[[[shared.fileNameContainer    objectAtIndex:shared.tempProjectNumber] objectAtIndex:indexPath.row]objectAtIndex:0]);
        }
        else
        {

            NSLog(@"array: %@",[[[[shared.fileNameContainer objectAtIndex:shared.tempProjectNumber] objectAtIndex:indexPath.row]objectAtIndex:0]class]);
        }

    cell.textLabel.text = [[[shared.fileNameContainer objectAtIndex:shared.tempProjectNumber] objectAtIndex:indexPath.row]objectAtIndex:0];

    };

    return cell;
}

in here, shared.tempProjectNumber is the recorded index of the project array (highest level of arrays within my main array, which is shared.fileNameContainer). 在这里,shared.tempProjectNumber是项目数组的记录索引(我的主数组中最高级别的数组,即shared.fileNameContainer)。 This is the recording I got for that post earlier, and after all the items of the table has been loaded, and I take it is the last item which causes the problem, I receive the sigbart error!! 这是我早些时候为该帖子获得的记录,并且在加载了表格的所有项目之后,我认为这是导致问题的最后一个项目,我收到sigbart错误! Thanks a lot Mundi 非常感谢Mundi

update: I have found an easier way to tackle my problem, so not much need of going further, but appreciate anyone shed some light on the matter 更新:我找到了解决我的问题的简便方法,因此没有太多需要做的事情了,但感谢有人对此事有所了解

regards 问候

Are you aware that in c and (most other programming languages) arrays are indexed from 0 to count-1 ? 您是否知道在c和(大多数其他编程语言)数组中索引从0count-1 Thus your array indices should go from 0 to 3 , not from 1 to 4 . 因此,数组索引应该从03 ,而不是14

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 UITableView的单元格不能用作设置 - UITableView's cell doesn't work as setting 在UITableView中批量插入时,第一个单元格的insertRowAnimation不起作用 - insertRowAnimation for the first cell doesn't work when batch inserting in UITableView CLLocationManager不适用于UITableView第一页上的单元格 - CLLocationManager doesn't work for cells on first page of UITableView ReloadData(UITableView)不起作用 - ReloadData (UITableView) doesn't work ContentInsets不适用于UITableView - ContentInsets doesn't work for UITableView UITableView的可访问性不起作用 - Accesibility for UITableView doesn't work UITableView reloadData不起作用 - UITableView reloadData doesn't work 如果只有一个项目,则UITableView scrollToRowAtIndexPath不会滚动到第一行 - UITableView scrollToRowAtIndexPath doesn't scroll to the first row if it only has one item 在非弹跳UITableView中滚动后,在第一次点击时行选择不起作用 - Row selection doesn't work on first tap after scroll in a non-bouncing UITableView 为什么第一次滚动到另一个UITableView中的UICollectionView中的UITableView不会加载数据? - Why does my UITableView within a UICollectionView within another UITableView doesn't load data when scrolled to it for the first time?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM