如何实现像 iPhone 上的电子邮件地址那样的自动选择文本框?
在 iPhone 的邮件应用程序上,您可以输入多个邮件地址...然后要删除一个,只需点击它,然后单击“删除”。我如何在我的应用程序中实现类似的功能? 我尝试处理 UITextView 上的点击,但看起来此类及其子类没有触发 TouchBegan 和相关委托方法:(
有什么想法吗?
On the iPhone's mail app, you can type in multiple mail addresses...and then to delete one you just tap it, and click Del. How can I implement something similar in my app? I tried to handle the tap on a UITextView, but it looks like the touchesBegan and related delegate methods are not fired for this class and its subclasses :(
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可能会有所帮助:链接
This could be helpful: Link
我实现了一个与 mail.app 中的视图相同的视图。 我使用了一个由自定义 UIView 组成的复合视图,其中包含一些其他类型的视图。 我使用 UITextField 来输入文本。 当用户完成地址时,我将文本放置在带有自定义背景图像的按钮中(以获得文本周围的气泡外观),并将 UITextField 移至右侧(或视情况移至下一行) 。 当用户点击地址“气泡”之一时,它就会被选中。 如果他们按下删除键,我会从视图中删除该气泡并重新布局所有内容。 这是一个使用许多有趣的边缘情况构建的不平凡的视图。
I have implemented a view that is identical to what is found in the mail.app. I used a composite view comprised of a custom UIView which houses a couple of other types of views. I used a UITextField for the text entry. As the user completes an address I take the text and place it in a button with a custom background image (to get the bubble around the text look) and move the UITextField to the right (or to the next line as the case may be). When the user taps one of the address "bubbles" it is selected. If they hit the delete key I remove that bubble from the view and re-layout everything. This is a non-trivial view to build with lots of fun edge cases.
查看 Joe Hewitt Three20 项目,它包括可以做这样的事情的“更好的文本字段”。
Check out Joe Hewitt three20 project, it includes "Better text fields" which can do such thing.