1

I want to know how can I get all sub views of any UITableview cell. So please suggest any suitable answer. Thank you.

ajeet sharma
  • 753
  • 9
  • 33

5 Answers5

0

This is it : getting for 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]]){}
                  }
        }
Kumar KL
  • 15,176
  • 9
  • 37
  • 59
0
 NSArray* subViews = [cell subviews];
Kumar KL
  • 15,176
  • 9
  • 37
  • 59
Tony Thomas
  • 937
  • 9
  • 19
0

if you want to recursively access all the views of the cell, check out: view recursion

Community
  • 1
  • 1
cohen72
  • 2,503
  • 25
  • 38
0

Assuming cell is your UITableViewCell

for(int i = 0; i < cell.contentView.subviews.count; i++)
{
     NSString *className = NSStringFromClass([[cell.contentView.subviews objectAtIndex:i] class]);
}
MuhammadBassio
  • 1,590
  • 10
  • 12
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
  }
}
iPatel
  • 43,583
  • 14
  • 113
  • 135