MOLH icon indicating copy to clipboard operation
MOLH copied to clipboard

Supporting UITextView

Open MoathOthman opened this issue 6 years ago • 6 comments

ref: https://medium.com/@omarhasan9394/great-work-thanks-2cc09eddb632

I have problem when add TextView textAligment right or left no change staill in one direction when switch language

notes: this might be as the same as with the textfield or related.

acceptance criterea ; ~the text input direction should follow the language direction.~ placeholder alignment to match the language direction

MoathOthman avatar Apr 27 '18 18:04 MoathOthman

According to my experiments for tracing the issue, it seems that UIKeyInput components alignment does not get affected by semanticContentAttribute. Note that not all components with textAlignment have this issue since the UILabel responds to semanticContentAttribute effect iff its textAlignment is natural, however even if the textAlignment for a UIKeyInput is natural it won't change its alignment.

In general, there are similar issues related to this one, for instance: https://github.com/Skyscanner/SkyFloatingLabelTextField/issues/109.

So far, we have to explicitly change textAlignment for the UIKeyInput components.

@MoathOthman please advice.

AhmadFayyas avatar Apr 29 '18 08:04 AhmadFayyas

@AhmadFayyas thank you for your insights , that seems legit since the the direction of the text should depends on the direction of the user input , yet what we are trying to solve here is a bit different since we just need to make the placeholder alignment looks the same as with the other components.(my bad wrong acceptance criteria, will fix it @AhmadFayyas ) currently its applied to the uitextField, but its not perfect though .

for subview in self.subviews {
            if let label = subview as? UILabel {
                label.tag = self.tag
            }
        }

the issue with the above code is that it will change the direction once the user start editing to the wrong direction ,

we have to explicitly change textAlignment for the UIKeyInput components is that possible ? .

MoathOthman avatar Apr 29 '18 11:04 MoathOthman

Ok, so let's split the issue to make it more clear.

For the text field:

is this the expected result? apr-30-2018 14-52-31

At some point we could change the alignment of the placeholder itself and enforce the text alignment to be the desired one, regardless of what's the used language.

For the text view:

obviously, there is no placeholder by default. I assume that the fix should be to enforce it to the desired text alignment...

AhmadFayyas avatar Apr 30 '18 11:04 AhmadFayyas

I think what you have done for the textfield is great if we can only make the placehold alignment to match the user input language direction so arabic start feom right always, If you can make a PR and we can take this from there, For text view we will keep this issue open and dedicated for textView . Thoughts?

Sent from my iPhone

On Apr 30, 2018, at 1:55 PM, Ahmad Fayyas <[email protected]mailto:[email protected]> wrote:

Ok, so let's split the issue to make it more clear.

For the text field:

is this the expected result? [apr-30-2018 14-52-31]https://user-images.githubusercontent.com/15219320/39425948-6dac5d76-4c86-11e8-845d-db40033faafc.gif

At some point we could change the alignment of the placeholder itself and enforce the the text alignment to be the desired one, regardless of what's the used language.

For the text view:

obviously, there is no placeholder by default. I assume that the fix should be to enforce it to the desired text alignment...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/MoathOthman/MOLH/issues/8#issuecomment-385377330, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABHNh9sY3DV_IpuYAo6HyeWiHekMUjD0ks5ttvvAgaJpZM4Tq2A0.

MoathOthman avatar Apr 30 '18 12:04 MoathOthman

I am facing the same issue. When I switch the language to Arabic and I use English keyboard; the cursor will start from LTR instead of RTL. However, it will start from RTL when I change my keyboard language to Arabic. Any solution to fix that?

I found a solution but it will be a repeating code for every view in the storyboard.

If the app is Arabic, it will use the following code: textfield.textAlignment = .right If the app is English, it will use the following code: textfield.textAlignment = .left

Any chance to use a function that will update all the textfields and textviews alignment in the application after changing the language?

alielephant avatar Jul 12 '18 13:07 alielephant

@alielephant its tricky one , if you have a fix please don't hesitate to submit a pr.

MoathOthman avatar Jul 15 '18 11:07 MoathOthman