Multi-line UITableViewCell using UITableViewCellStyleValue2 style

前端 未结 4 420
暗喜
暗喜 2020-12-24 14:50

I\'m trying to figure out how to replicate the UITableViewCellStyleValue2 style so that the detail text can be multiple lines - as seen in the \'address\' cells in the Conta

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-24 15:31

    Create a custom cell for you table and place a UILabel and a UITextView inside it. Position the label & text view to match their x,y positions to the other cells you are using in that table. You insert "\n" in the textview's text wherever you want line breaks to occur. You resize the textview height depending on the number of lines in the textview using something like:

    CGRect frame = yourTextView.frame; frame.size.height = yourTextView.contentSize.height; yourTextView.frame = frame; return frame.size.height + 20.0; // Pad the cell's height as necessary for your applicaion

提交回复
热议问题