Skip to content

Conversation

@hyowon612
Copy link
Collaborator

@hyowon612 hyowon612 commented Jan 16, 2025

⭐️Issue


🌟Motivation

FeedEditView 이모지 깨지는 문제 해결

🌟Key Changes

원인

  • 기존에 커서 위치를 복원하기 위해 selectedRange.location 과 feedContent.count 를 사용함.
    ([Fix] #399 - 수다글 엔터 키 입력 시 커서가 맨 끝으로 이동하는 문제 해결 #400 참고.)
  • 커서 위치를 복원할 때 사용하는 selectedRange.locationUTF-16 인덱스를 기반으로 커서 위치를 반환.
  • feedContent.count 는 Swift String의 Character 개수(유니코드 스칼라)를 반환.
  • UTF-16과 유니코드 스칼라 간의 차이로 인해 커서 위치가 정상적으로 복원되지 않으면서 조합문자인 이모지가 분리되는 현상 발생.

해결

  • 커서 복원 작업을 UITextView의 UITextPosition 및 offset(from:to:) 메서드를 활용하여 UTF-16 인덱스를 기준으로 작업하도록 변경.

🌟Simulation

➡️


🌟To Reviewer

행간/자간 적용을 위해 AttributedString를 사용하면서 이런 문제들이 많이 발생하네요..
AttributedString 안 쓰고 행간/자간 적용하는 방법은 없나?

🌟Reference


@hyowon612 hyowon612 self-assigned this Jan 16, 2025
@hyowon612 hyowon612 requested review from Guryss and ena-isme and removed request for ena-isme January 16, 2025 06:29
Copy link
Member

@Guryss Guryss left a comment

Choose a reason for hiding this comment

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

천재만재시네 .... 저뇨원 최고
근데 진짜 attributedString을 사용하지 않고 행, 자간 적용할 수 있는 방법을 찾아봐야겠네여 ...
이걸 사용해서 오히려 버그 잡기 위한 코드가 길어지는 느낌 ..... 🥲

Copy link
Contributor

@Naknakk Naknakk left a comment

Choose a reason for hiding this comment

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

고생했습니다 ! 상당히 어려워지네요 . .

Copy link
Member

@ena-isme ena-isme left a comment

Choose a reason for hiding this comment

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

진짜 어떻게 헀대 ?
관련 오픈소스가 있을 것 같기두 하구,,,
같이 찾아봅세다 !

@hyowon612 hyowon612 merged commit 8fc6caf into main Jan 17, 2025
@hyowon612 hyowon612 deleted the Fix/#411 branch January 17, 2025 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fix] UITextView 이모지 깨지는 문제 해결

5 participants