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

fix added to end of text#48

Open
ghost wants to merge 2 commits into
ilyapuchka:masterfrom
RettyInc:feature/fix-addedto-end-of-text
Open

fix added to end of text#48
ghost wants to merge 2 commits into
ilyapuchka:masterfrom
RettyInc:feature/fix-addedto-end-of-text

Conversation

@ghost

@ghost ghost commented Feb 22, 2019

Copy link
Copy Markdown

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

@sltc-li sltc-li left a comment

Copy link
Copy Markdown

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
Copy Markdown

how to scroll after read more action ?

@harish2223

Copy link
Copy Markdown

textview scroll is not showing ?

@ghost

ghost commented Apr 10, 2019

Copy link
Copy Markdown
Author

oh Dog!
LGTM?

Repository owner deleted a comment Apr 12, 2019
@ablyNiteshKumar

Copy link
Copy Markdown

Its not Working on RTL

@KNG-Dev

KNG-Dev commented May 15, 2020

Copy link
Copy Markdown

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

@keisukeYamagishi

keisukeYamagishi commented May 16, 2020

Copy link
Copy Markdown

Hi! @ilyapuchka
Shouldn’t we closed once?

@avinashvaghasiya

Copy link
Copy Markdown

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

Mayur312 commented Apr 20, 2021

Copy link
Copy Markdown

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