MOLH
MOLH copied to clipboard
Supporting UITextView
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
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 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 ? .
Ok, so let's split the issue to make it more clear.
For the text field:
is this the expected result?
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...
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.
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 its tricky one , if you have a fix please don't hesitate to submit a pr.