0

My question is how to replace uitextField with uitextView when i touch the uitextField. What can i do in this situation? i tried to add uitextView and then add uitextField in the same area and when i touch the uitextField it will removed but it doesn't work. my code is

textField.enabled = false

Maybe my code is not right or my idea. I do this to have Placeholder in UITextView like this video and I thought that this is the best way to have it because i tried many ways but all do not work perfectly. I need your help guys .

J.S.O
  • 111
  • 1
  • 13

1 Answers1

0

It's the property hidden that you should use and not enabled. With the latter you can control if the user can interact with the view (enabled = true) or not (enabled = false) The former instead make the view invisible when set to true and visible otherwise. What you want is to do this

textField.hidden = true
textView.hidden = false 

after the user tap on the textField. Be sure to have the textView already in the right place where you want it to appear. You might also want to handle the keyboard :)

Why don't you use a UITextView directly from the beginning?

coder.pm
  • 71
  • 2
  • 8
  • thank you for your answer, i need Placeholder in UITextView and I thought that this is the best way to have it. But i have problem ,efter i touch textField i most touch the textView also to right something – J.S.O Mar 02 '16 at 15:04
  • If you only need a textView with placeholder feature, you could have a look at http://stackoverflow.com/questions/1328638/placeholder-in-uitextview – coder.pm Mar 02 '16 at 15:07
  • i tried this [link](http://stackoverflow.com/questions/1328638/placeholder-in-uitextview/26674907#26674907) but ti doesn't work perfect ,when you touch the textView placeholder disappears but when touch anything else you will not have the placeholder again and you must stop the app and run it again to have placeholder in your textView :( – J.S.O Mar 02 '16 at 15:33