nstextattachment

Detect Tap On Image's Attached In NSAttributedString While UITextVIew Editing Is True

你。 提交于 2019-12-22 10:59:37
问题 I'm using Below method for detecting taps on image in UITextView . `func textView(_ textView: UITextView, shouldInteractWith textAttachment: NSTextAttachment, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool` This method only call when textView.isEditable = false . So then i add UITapGestureRecognizer on UITextView and it calls when user tap on image inside UITextView . But that point i don't know how i can detect on which image user tap if there is more than one inside

How to implement a horizontal rule in a text view?

北城余情 提交于 2019-12-20 04:39:12
问题 Say I have an NSTextView (or a UITextView on iOS) and I want the user to be able to insert horizontal divider rules, like the HTML <hr> tag or this thing: What's the best way to implement this? Apple's documentation is very thing on this. So far, I have two ideas: Insert an NSTextAttachment for each rule and make the layout manager draw it somehow. Instead of a single text view, use multiple text views with scrolling disabled, put them in a stack view, add separator views between them and

How to replace a text attachment with a custom drawing with NSLayoutManager?

≡放荡痞女 提交于 2019-12-19 08:28:11
问题 My ultimate goal is to give the user the ability to split a text inside an NSTextView or UITextView into several sections , where two subsequent sections are visually separated by a custom view separator (possibly, but not necessarily a horizontal rule – I want to be able to adjust the visual appearance of the separator without a hassle). I need a solution that works on both platforms: macOS and iOS . (My related question focused on a solution for macOS and there is one that makes use of

How to detect touch on NSTextAttachment

和自甴很熟 提交于 2019-12-18 11:09:46
问题 What is the best way to detect when user taps on NSTextAttachment on iOS? I think that one of the ways would be checking for the character on carret's position whether it is NSAttachmentCharacter , but it just doesn't seem right. I've also tried UITextViewDelegate method: -(BOOL)textView:(UITextView *)textView shouldInteractWithTextAttachment:(NSTextAttachment *)textAttachment inRange:(NSRange)characterRange but it's not invoked when textView.editable=YES 回答1: The delegate method does work

Center NSTextAttachment image next to single line UILabel

我是研究僧i 提交于 2019-12-17 08:01:41
问题 I'd like to append an NSTextAttachment image to my attributed string and have it centered vertically. I've used the following code to create my string NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:DDLocalizedString(@"title.upcomingHotspots") attributes:attrs]; NSTextAttachment *attachment = [[NSTextAttachment alloc] init]; attachment.image = [[UIImage imageNamed:@"help.png"] imageScaledToFitSize:CGSizeMake(14.f, 14.f)]; cell.textLabel.attributedText = [str

NSTextAttachment image not displayed on iOS 8 devices (with iOS7.1 sdk)

北慕城南 提交于 2019-12-13 00:44:58
问题 I have just built my project on several iOS 8 devices with baseSDK set to iOS 7.1. Unfortunately, all NSTextAttachment images added as attributes to relevant instances of NSMutableAttributedString are hidden on iOS 8 devices and the iOS 8 simulator (they are still visible on devices with 7.1 and the iOS 7.1 simulator). The frame for these strings within their superviews is set as if the image was there, but the image itself is just not visible or rendered. Has anybody else ran into the issue

Scaling NSTextAttachment in NSPasteboard

故事扮演 提交于 2019-12-11 04:14:27
问题 I have an NSTextAttachment which contains an NSImage . What I would like to do is scale this image so that it's smaller in dimensions but will keeping the same number of pixels. Then moving it to the general pasteboard. Once it's pasted (into whatever app) I would like it to paste with the same dimensions I just set. The problem I am having is that pasting it in any other app always puts it at is original dimensions. I have tried the following things and none seem to fully work First is

iOS文本布局探讨之三——使用TextKit框架进行富文本布局

心不动则不痛 提交于 2019-12-10 13:33:21
iOS文本布局探讨之三——使用TextKit框架进行富文本布局 一、引言 关于图文混排,其实以前的博客已经讨论很多,在实际开发中,经常使用第三方的框架来完成排版的需求,其中RCLabel和RTLabel是两个比较好用的第三方库,他们的实现都是基于UIView的,通过更底层的CoreText相关API来进行图文处理。相关介绍博客地址如下: iOS中支持HTML标签渲染的MDHTMLLaebl: http://my.oschina.net/u/2340880/blog/703254 。 扩展于RCLabel的支持异步加载网络图片的富文本引擎的设计: http://my.oschina.net/u/2340880/blog/499311 。 iOS开发封装一个可以响应超链接的label——基于RCLabel的交互扩展: http://my.oschina.net/u/2340880/blog/550194 。 二、原生UILabel真的只能渲染文字么? CoreText是一个比较底层且十分强大的文本渲染框架,但是其使用起来并不是十分方便。在较低版本的iOS系统中,要进行富文本排版十分困难。在iOS6中,系统为UILabel,UITextView等这类文本渲染控件引入了NSAttributedString属性,有了NSAttributedString这个类

NSAttributeString Height seems align wrong when use both image and text

爱⌒轻易说出口 提交于 2019-12-10 11:48:09
问题 I have a uilabel in tableviewcell ,and the label use NSAttributeString to support both image and text. But I found when the label contains image or text only , the height of label is correct ,but when label contains image and text both ,the height seems not correct .the row height seems little more big than the actual height need and if there is text or images only ,the height is right and I was using my Own subclass from NSTextAttachment to construct image and the attachment code is like

iOS 7 UITextView: Size of nstextattachment getting 2x after reopening the application

北慕城南 提交于 2019-12-10 04:22:30
问题 I am building a note editor using the Text Kit in ios7. Earlier I had trouble in rendering of custom size NSTextAttachment's as it was slowing down the rendering to a great extent.I solved the issue by scaling the images and then adding them to textview.You can find my answer in iOS 7.0 UITextView gettings terribly slow after adding images to it After scaling the images the textview rendering runs fine without any lag.The attributed text of textview is stored in core data.During a running