ReadMoreTextView icon indicating copy to clipboard operation
ReadMoreTextView copied to clipboard

fix added to end of text

Open ghost opened this issue 6 years ago • 8 comments

There are times when a character string is added to the end of attributedText. I was thinking that it would be useful as a means to remedy the phenomenon, and I made a PR.

_needsUpdateTrim was true with the following function _originalAttributedText is substituted and modified,

but

public override func layoutSubviews () {
         super.layoutSubviews ()
        
         if _needsUpdateTrim {
             / / reset text to force update trim
             attributedText = _originalAttributedText
             _needsUpdateTrim = false
         }
         needsTrim ()? showLessText (): showMoreText ()
     }

i think Please confirm that this is more stronger PR created

best regards

ghost avatar Feb 22 '19 06:02 ghost

how to scroll after read more action ?

harish2223 avatar Mar 27 '19 11:03 harish2223

textview scroll is not showing ?

harish2223 avatar Mar 27 '19 11:03 harish2223

oh Dog! LGTM?

ghost avatar Apr 10 '19 13:04 ghost

Its not Working on RTL

ablyNiteshKumar avatar Oct 31 '19 11:10 ablyNiteshKumar

Anyone have an idea why the func hitTest gets called twice?

KNG-Dev avatar May 15 '20 14:05 KNG-Dev

Hi! @ilyapuchka Shouldn’t we closed once?

keisukeYamagishi avatar May 16 '20 06:05 keisukeYamagishi

Simulator Screen Shot - iPhone 6 - 2020-07-08 at 14 44 33

hello, i have issue in text with emoji so look this issue

avinashvaghasiya avatar Jul 08 '20 09:07 avinashvaghasiya

Simulator Screen Shot - iPhone 6 - 2020-07-08 at 14 44 33

hello, i have issue in text with emoji so look this issue

In ReadMoreTextView.swift > showMoreText() method, replace text.unicodeScalars.count with text.length. The final method will be:

private func showMoreText() { if let readLessText = readLessText, text.hasSuffix(readLessText) { return }

shouldTrim = false
textContainer.maximumNumberOfLines = 0

if let originalAttributedText = _originalAttributedText?.mutableCopy() as? NSMutableAttributedString {
    attributedText = _originalAttributedText
    let range = NSRange(location: 0, length: text.length)
    if let attributedReadLessText = attributedReadLessText {
        originalAttributedText.append(attributedReadLessText)
    }
    textStorage.replaceCharacters(in: range, with: originalAttributedText)
}

invalidateIntrinsicContentSize()
invokeOnSizeChangeIfNeeded()

}

Mayur312 avatar Apr 20 '21 06:04 Mayur312