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
  • 803
  • 10
  • 37

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,315
  • 9
  • 38
  • 60
0
 NSArray* subViews = [cell subviews];
Kumar KL
  • 15,315
  • 9
  • 38
  • 60
Tony Thomas
  • 967
  • 10
  • 20
0

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

Community
  • 1
  • 1
cohen72
  • 2,830
  • 29
  • 44
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
  • 13
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
  • 46,010
  • 16
  • 115
  • 137