2

如何在 textview 中添加按钮?例如..

textView.text=@"text here\n\n text also here\n\n text here aswell";

如何在每个“\n\n”之后或沿文本添加按钮?

4

2 回答 2

1

您可以创建一个对象UIButton并将其作为子视图添加到 yout textview

需要预先设置按钮的边框所以文字必须是统计的,并且必须提前知道按钮的位置。

于 2012-08-23T09:07:40.170 回答
0

so your \n\n creates a paragraphs

You can do it without static text just split your text in separate textviews by \n\n, add them to your scrollview. You have to measure your text paragraphs height to set the right frame for textviews and leave gaps for buttons. I would rather use tableview so you dont have to worry about that. Add buttons in between, it is doable.

you may reconsider adding buttons along the text this way (you can but it is really convoluted way of doing things), use webview for that as already stated here by others

于 2014-04-02T16:44:28.187 回答