unrecognized selector sent to instance 问题的解决方法

 

在一个tableView中加入两个自定义cell时,出现了如下错误,在网上找了一下出现这个问题的原因很多。我所遇到的是第二次加载第二个cell时,才会出现。

'-[NSIndexPath setTableViewStyle:]: unrecognized selector sent to instance 0x7fb28b0

 

解决方法:

在定义cell时,加入

        if([[cell.contentView subviews] count] >0)
        {
            for (UIView *temp in [cell.contentView subviews]) {                
                [temp removeFromSuperview];
            }            
        }

posted @ 2012-08-15 21:01  superchao  阅读(688)  评论(0编辑  收藏  举报