I have a layout
in which I will have 2 UITableViews
with custom cells
. The second UITableView
must be inside the first.
My question is: how to delegate second UITableView
?
Can I delegate both to my ViewController
? In that case it will use the same methods and I have to find out which UITableView
is managed right now.
Or I have to delegate it inside custom UITableViewCell
of the first UITableView
?
Any recommendations are appreciated.
EDIT: I don't know how to implement solutions here, because I have Storyboard
. Inside my current UIViewController
I set delegate
and dataSource
of the first UITableView
to my View Controller.
My problem is that I don't know how to set the same properties of the second Table View (which will be inside UITableViewCell
). I can not set them to UITableViewCell
(IB does not allow that).
Where and how to set then in the IB?
You just check table condition for every delegate method
Use this code to register custom cell.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(tableView == self.yourFirstTable)
{
CustomCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cellModifier"];
// your code
}
else
{
// second table cell code
}
return cell;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(tableView == self.yourFirstTable)
{
// first tableView number of row return
}
else
{
// second table number of row return
}
}
And create prototype cell in TableView
And Set CellReusableId like this way