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];
            }            
        }

原文地址:https://www.cnblogs.com/superchao8/p/2640778.html