单元格子视图的对象

时间:2014-01-30 08:47:54

标签: ios uitableview

我想知道如何获取任何UITableview单元格的所有子视图。  所以请提出任何合适的答案。 谢谢。

5 个答案:

答案 0 :(得分:0)

就是这样:获取tableView SubViews。

  int sections = [self.tableView numberOfSections];// Only for the 1 row with many Sections && if many Rows then //[self.tableView numberOfRowsInSections:sections];
        for (int i=0; i<sections; i++) {

            NSIndexPath *myIP = [NSIndexPath indexPathForRow:0 inSection:i] ;
            UITableViewCell *cell =[self.tableView cellForRowAtIndexPath:myIP];

            NSArray *subviews = cell.contentView.subviews;//For perticular cell

                for(id element in subviews) {
                  //if ([element isKindOfClass:[UITextView class]]){}
                  }
        }

答案 1 :(得分:0)

 NSArray* subViews = [cell subviews];

答案 2 :(得分:0)

如果您想recursively access all the views of the cell,请查看:view recursion

答案 3 :(得分:0)

假设cell是您的UITableViewCell

for(int i = 0; i < cell.contentView.subviews.count; i++)
{
     NSString *className = NSStringFromClass([[cell.contentView.subviews objectAtIndex:i] class]);
}

答案 4 :(得分:0)

for(UIView *subView in cell.contentView.subviews) 
{
   // Get all subView
   if([subView isKindOfClass:[UITextField class]]) // here you can set any class name which you need to get it.
  {
      // Get specific class from subView
  }
}