如何在注释字幕中自动换行
我尝试将回车符和换行符插入到字幕字符串中,但它们最终成为“空格”而不是换行符。由于 subtitle 只是一个 NSString,我必须查看容器,这可能意味着我必须滚动自己的注释视图。
NSString 确实变成了 f.ex。 “90510\nHollywood, CA”,但也许我必须对换行符进行“编码”,或者使用 NSString 的子类发送到字幕?
让我困惑的是,字幕应该能够“可换行”,因为 MKAnnotation(view) 通过调整气泡大小和添加“...”等来处理太长的文本。
对于稍后添加的一段文本,我确实需要适当的自动换行(而不是硬换行符),但我可以将其作为单独的警报或模式框类型来执行,如果您知道哪些支持自动换行,我会如果您能建议他们,我将不胜感激。
预感是,通过添加 UILabel 作为子视图,或者以某种方式访问用于显示副标题的 UILabel(?) 并将其 numberOfLines 设置为 0,可以实现某些功能,但我不知道如何执行后者。
I tried to insert return and newline chars into the subtitle string, but they ended up as "spaces" and not line breaks. Since subtitle is simply an NSString I must look at the container, which likely means I'll have to roll my own annotation views.
The NSString do become f.ex. "90510\nHollywood, CA", but maybe I have to 'encode' the newlines instead, or use a subclass of NSString to send to subtitle?
What baffles me is that surely, subtitle should be able to "be wrappable", as the MKAnnotation(view) handles too long text by resizing the bubble and adding "...", et cetera.
I do need proper word wrap (and not hard line breaks) for a paragraph of text I'm adding later, but I could possibly do that as a separate alert or modal box type, if you know which ones support word wrap I'd be grateful if you could suggest them.
A hunch is that something could be possible by adding a UILabel as a subview, or somehow access the UILabel(?) that is used to display the subtitle, and set its numberOfLines to 0, but I don't know how to do the latter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AFAIK 这是不可能完成的。设置左/右按钮文本确实受到空间限制。似乎唯一的解决方案是添加观察者并完全滚动您自己的动画视图。
AFAIK it can't be done. Setting left/right button text is space-limited indeed. Seems the only solution is to addObserver and roll your own animated views entirely.