ios - placeholder is not taking NSTextAlignmentNatural -


i have app have uitextfield.

my app english - arabic app.

now have below.

addpostvideourl.backgroundcolor = [uicolor clearcolor]; addpostvideourl.textalignment = nstextalignmentnatural; <-- setting alignment addpostvideourl.textcolor = pgray_343434; addpostvideourl.placeholder = localize(@"videourl"); [addpostvideourl setvalue:pgray_343434 forkeypath:@"_placeholderlabel.textcolor"]; addpostvideourl.font = [self adjustdefaultfont:40]; addpostvideourl.autocorrectiontype = uitextautocorrectiontypeno; 

if see, have set alignment text nstextalignmentnatural. did because if keyboard arabic (& app english or arabic), want textfield start right side.

with when changed keyboard english, text field start ltr & if change keyboard arabic, textfield start rtl. however, placeholder have @ left.

any way how can make placeholder alignment based on app language?

to tackle issue, below did...

  1. in .pch add below

    #define mydirection001 ([localize(@"mylang") isequaltostring:@"en"]) ? nstextalignmentleft : nstextalignmentright

  2. then have code below.

    addpostvideourl.backgroundcolor = [uicolor clearcolor]; addpostvideourl.textalignment = mydirection001; addpostvideourl.textcolor = pgray_343434; addpostvideourl.placeholder = localize(@"videourl"); [addpostvideourl setvalue:pgray_343434 forkeypath:@"_placeholderlabel.textcolor"]; addpostvideourl.font = [self adjustdefaultfont:40]; addpostvideourl.autocorrectiontype = uitextautocorrectiontypeno; 

make sure delegate set going call delegates now.

  1. call delegate methods.

    - (bool)textfieldshouldbeginediting:(uitextfield *)textfield {     textfield.textalignment = nstextalignmentnatural;         return yes; }  - (bool)textfieldshouldreturn:(uitextfield *)textfield{     textfield.textalignment = (textfield.text.length==0) ? mydirection001 : nstextalignmentnatural;     return yes; } 

Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -