0

I'm using UIListContentConfiguration to config cell properties on iOS 14. The cell's style is standard Right Detail. I was able to set the detail text field displaying in multiple lines on the right of the main text just using

cell.DetailTextLabel.Lines = 0 

But now I can't do the same thing with UIListContentConfiguration by using

content.SecondaryTextProperties.NumberOfLines = 0 

The secondary text jumps to a new line instead of staying on the right of the main text when it gets long.

What should I do?

It's written in C# MAUI but I think it's similar to native iOS as well:

public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { var cell = tableView.DequeueReusableCell(cellData, indexPath); cell.AccessoryView = null; cell.UserInteractionEnabled = false; cell.Accessory = UITableViewCellAccessory.None; var content = cell.DefaultContentConfiguration; content.Text = "Main text"; content.TextProperties.Color = UIColor.Black; content.SecondaryText = "Quite a longggggggggggggggg text"; content.SecondaryTextProperties.Color = UIColor.Gray; content.SecondaryTextProperties.NumberOfLines = 0; cell.SizeToFit(); cell.ContentConfiguration = content; return cell; } 
4
  • You may refer to this UITableView detailTextLabel equivalent in UIListContentConfiguration. Commented Nov 30, 2023 at 9:03
  • @LiqunShen-MSFT Thanks for the link. I already checked it and it says quite clearly that "If there's too much text to fit in the horizontal space available, then the labels will automatically stack vertically instead to avoid truncation." which is exactly I wanted to to. Commented Nov 30, 2023 at 9:12
  • I supposed the primary and secondary text would stack vertically. You could also try using a Custom cell to manage the layout. Commented Nov 30, 2023 at 9:18
  • @LiqunShen-MSFT Yes custom cell may be the only option for now. I'll give it a try. Thank you for your time. Commented Dec 1, 2023 at 1:07

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.