views:

43

answers:

2

Hi all,

In my project (my first one) I try to assign a text to a textfield created in the Interface Builder.

[date setText:@"2010"];

I also tried using

date.text = @"2010"

I have created the Outlet and don't get any error... the text just doesn't show up.

Just in case it matters... I prevent the keyboard from showing up and display a calendar instead (works).

Any idea what could be wrong?
Could it be a problem that I'm using delegate methods on the textFields to prevent displaying the keyboard?

A: 

Where are you trying to do this? In init method? Then it won't work as the IBOutlet connections are yet to be made. Try this in viewDidLoad method.

taskinoor
Hi,No, I'm trying to do it in a delegate method that is executed when a date has been selected.
Michi
A: 

If you don't want to edit text using a keyboard, then what is the use of UITextField? Instead of using UITextField you can use a UILabel (as a global variable) to show the text and use a custom UIButton without a title and use its action for showing the calendar view. You can change the text of the label whenever you want in that class like viewWillAppear or viewDidAppear.

Navnidhi
I think I might try that as my current implementation does not work.
Michi
I finally went this way... now I will be looking into styling the button to look like TextFields.
Michi