Problem Statement 1: Unable to align two custom cells text simultaneously for multiline, as shown below.
You can see here, for multi-line cell both the cell contents are not at same starting top line.
When there is no multiline content, then it is ok, as shown in below
You can see, how both the cell contents are aligned on same line properly.
Problem Statement 2: And there is one more problem, if cell is having large content, it won't increase it's height, instead of that it gets small font size as shown below
Below is my coding stuff, by this way I've managed for two custom cell with multiline.
func tableView(tableViewData: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = tableViewData.dequeueReusableCellWithIdentifier("cell")! as! StudentCell
if indexPath.row < self.mMeaningArray.count
{
cell.lblMeaning1.text = self.mMeaningArray[indexPath.row]
}
else
{
cell.lblMeaning1.text = ""
}
if indexPath.row < self.hMeaningArray.count
{
cell.lblMeaning2.text = self.hMeaningArray[indexPath.row]
}
else
{
cell.lblMeaning2.text = ""
}
self.allowMultipleLines(cell)
cell.lblMeaning1.layoutIfNeeded()
cell.lblMeaning2.layoutIfNeeded()
return cell
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{
return UITableViewAutomaticDimension
}
func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{
return UITableViewAutomaticDimension
}
func allowMultipleLines(tableViewCell:UITableViewCell)
{
tableViewCell.textLabel?.numberOfLines = 0
tableViewCell.textLabel?.lineBreakMode = NSLineBreakMode.ByWordWrapping
tableViewCell.textLabel?.sizeToFit()
}
I know, it is adjusting its font size, as per contents, but I want that, it should be a fixed font-size with multi-line and simultaneously it should align text properly.
I've search on various sites, links & refer multiple questions of stack-overflow, but for this situation, didn't find any solution.