UITableViewCell子视图仅返回iOS7中的UITableViewCellScrollView

D_D*_*D_D 6 objective-c uitableview ios ios7

我有UITableViewCell7个子视图的自定义.其中一个是活动视图,所以为了找到它并停止,我做这样的事情:

NSArray *subviews=[cell subviews];       
NSLog(@"Subviews count: %d",subviews.count);     
for (UIView *view in subviews)  
{                
  NSLog(@"CLASS: %@",[view class]);     
  // code here     
 }
Run Code Online (Sandbox Code Playgroud)

在iOS6中,子视图count:为7,其中一个是活动视图.但在iOS7中,Subviews count:为1,[view class]返回UITableViewCellScrollView.试过了, NSArray *subviews=[cell.superview subviews];并且 NSArray *subviews=[cell.contentview subviews];,却徒劳无功.

有什么建议?

rma*_*ddy 13

您需要以递归方式下降到每个子视图的子视图中,依此类推.永远不要对私有子视图结构做任何假设.更好的是,因为您只应该将子视图添加到单元格中contentView,只需查看,而contentView不是整个单元格.