0

I have a problem that really drives me crazy.

A few months ago i started developing an iphone application , and i needed to have a multiline textField so that the user could write some comments. In the end , because at the time i couldnt find a solution , i found a solution how to use a Text View instead which is by default multiline. In my project it seems that i have connected this Text View with a UITextField outlet.

Now i am trying to make my app universal , so i created a new .xib file for the iPad version.

However it seems impossible to connect the Text View that i created with the UITextField Outlet that i was using with the iphone .xib.

I m really breaking my head here to remember how on earth i connected these two in the first place. I remember that i implemented some delegate methods to customize the Text View to work as a Text Field , and it seems that all the properties of my iPad Text View are the same with the ones of the iPhone version. However i cant connect it with the outlet.

Does anyone have any idea , what i am missing here?

  • 3
    I don't think you can `UITextField` outlet to a `UITextView` – nsgulliver Mar 01 '13 at 11:58
  • Man its really there! I see the Text View of the iphone .xib file connected to a UITextField Outlet from the ¨Show the connections inspector!¨ Even when , i am in the assistant editor and watch side by side the .xib with the .h and i put my cursor on the connection area of the outlet , the Text View becomes blue! –  Mar 01 '13 at 12:03
  • 1
    I don't think it is the case, you should show the screenshot, it might help us to see what exactly is happening there, you might have named your `UITextView` as `UITextView *textField` or something – nsgulliver Mar 01 '13 at 12:07
  • no it is not possible. – KDeogharkar Mar 01 '13 at 12:11
  • see my answer to see what i did –  Mar 01 '13 at 12:21

3 Answers3

0

It is imposible connect UITextView to UITextField. There is no solution or tweak using which you can alter UITextView to behave like UITextField. You better use some third party library and use it in your project. I am still surprised how you did it in your iPhone project. Can you please share some code how you did in iPhone for better understanding of what you are asking.

DD_
  • 7,230
  • 11
  • 38
  • 59
abdus.me
  • 1,819
  • 22
  • 34
  • Man its really there! I see the Text View of the iphone .xib file connected to a UITextField Outlet from the ¨Show the connections inspector!¨ Even when , i am in the assistant editor and watch side by side the .xib with the .h and i put my cursor on the connection area of the outlet , the Text View becomes blue! –  Mar 01 '13 at 12:05
  • This is not possible. Please share some screen shot so that it will be helpful to understand. – abdus.me Mar 01 '13 at 12:17
0

Outlets can be connected to the same types only and they are pointing to the object of the same types and they have 1-to-1 relationship, you can not connect one outlet to multiple objects either.

You might have named your UITextView as UITextView *textField or something , you need to Connect your UITextField outlet to the corresponding textField in your classes, you can not connect UITextField to UITextView.

nsgulliver
  • 12,655
  • 23
  • 43
  • 64
0

It appears that after all is possible..

I tried the unthinkable and it worked..

I created a new outlet from my text View , a UITextView outlet and then... well i just renamed the UITextView to UITextField and works perfectly.. I connected both textViews (iPhone.xib and iPad.xib) in this outlet and it works.. (I connected them before renaming it to a UITextField outlet cause after that you cant connect them)

  • and don't tell me that delegate methods are working only by doing this what you did??? – nsgulliver Mar 01 '13 at 12:25
  • yeah everything works great. The textView works exactly like a multiline textField. –  Mar 01 '13 at 12:27
  • well i don't think it is happening exactly, you are only changing the field type after connecting it does not mean it will change the behavior of its delegate methods – nsgulliver Mar 01 '13 at 12:30
  • I dont understand what you mean. All i wanted was having a textView work like a textField. This is what i just did. The textView now behaves EXACTLY like a textField. You have a keyboard when clicking on it , you dismiss it , the text is stored in the outlet , everything works like a textField. Of course i used some delegate methods and customize things to do that , but the final step was to connect the textView to the textField outlet to accomplish it. I just couldnt remember how the hell i connected it. That was the way. –  Mar 01 '13 at 12:33
  • @d0nparalias You to realize that you didn't have to try to trick Xcode in order to do this. UITextFieldDelegate and UITextViewDelegate both exist. – Mick MacCallum Mar 01 '13 at 12:43
  • Of course. But thats the way i did it for the iPhone and i was just curious what the hell was i doing and made it work at the time. Now i understand. –  Mar 01 '13 at 12:45