Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

fix added to end of text #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

fix added to end of text #48

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Feb 22, 2019

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 ghost changed the title fix addedto end of text fix added to end of text Feb 22, 2019
Copy link

@sltc-li sltc-li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved this by accident (plz ignore it)

@harish2223
Copy link

how to scroll after read more action ?

@harish2223
Copy link

textview scroll is not showing ?

@ghost
Copy link
Author

ghost commented Apr 10, 2019

oh Dog!
LGTM?

Repository owner deleted a comment Apr 12, 2019
@ablyNiteshKumar
Copy link

Its not Working on RTL

@KNG-Dev
Copy link

KNG-Dev commented May 15, 2020

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

@keisukeYamagishi
Copy link

keisukeYamagishi commented May 16, 2020

Hi! @ilyapuchka
Shouldn’t we closed once?

@avinashvaghasiya
Copy link

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

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

@Mayur312
Copy link

Mayur312 commented Apr 20, 2021

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()

}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants