用于 ChatRoom 应用程序的最佳 UI 控件是什么?
我想创建一个简单的聊天室,如 GUI 界面,它将为以下格式的每一行创建一个条目:
Person1: Hello world!
Person2: Hello there.
Person3: What's up?
Person1: not much
其中第 2 个人和第 3 个人将是蓝色。 Person1 将是读取颜色。
如果用户愿意,他们可以单击 Person2 或 person2 的文本行,然后将显示他们的个人资料。
他们还应该能够上下滚动聊天室的历史记录。
我的问题如下:
1.) 允许我执行此操作的最佳 UI 控件是什么? 2.) 有源代码示例吗?
提前致谢。
I would like to create a simple chat room like GUI interface that will create an entry for each line spoken in the following format:
Person1: Hello world!
Person2: Hello there.
Person3: What's up?
Person1: not much
Where Person 2&3 will be a blue color. Person1 will be a read color.
If the user wanted, they can click on Person2 or person2's text line and will bring up their profile.
They should also be able to scroll up and down the chat room's history.
Here's my questions:
1.) What's the best UI controls to allow me to do this?
2.) Are there source code examples anywhere?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我过去的做法是将 uibutton 作为 uiscrollview 的子视图。 UIButton 允许您在其上拉伸图像,类似于 SMS 应用程序,然后您还可以响应用户选择的文本。
要使按钮像 SMS 应用程序一样显示为气球:
您还可以使用 UIViews,但使用 UIButton 可以获得很多好处,例如添加对齐文本、按下时的轻松回调以及选择时可以访问内部文本的不同控制状态他们。这在实现复制和粘贴时非常方便。
不幸的是,您必须计算文本的长度来确定按钮的大小,但网上应该有相关示例。
The way I have done it in the past is a uibutton as a subview of uiscrollview. UIButton allows you to stretch an image across it similar to that of the SMS app, then you can also respond to the user selecting the text.
To make the button appear like a balloon like the SMS app:
You could also use UIViews but you get a lot of nice things with UIButton like adding text with alignment, easy callbacks when pressed and different control states when selected with access to the text inside them. This can be handy when implementing copy and paste.
You will have to calculate how long your text will be to determine the size of your button unfortunately but there should be examples on the net for that.