0

I'm trying to display a user's messages in a watchOS app and I'm using a WKInterfaceTable instance to do so.

I would like outgoing messages to be right-aligned and incoming messages to be left-aligned but I can't get it to work. Here is the code I'm using:

let row = mainTable.rowController(at: index) as! MessagesViewTableRowController
row.rowLabel.setText(messageText!)
row.rowLabel.setSemanticContentAttribute(.forceLeftToRight)
if outgoing == 1 {
    row.rowLabel.setSemanticContentAttribute(.forceRightToLeft)
}

The line that sets the semantic to right is being executed but it's having no effect on the alignment of the row. Everything is remaining left-aligned.

1 Answers1

1

I figured it out.

The label needed its width to be set to "Relative to Container" with a value of 1. After setting that in the storyboard, my code is working.