Note that there are some explanatory texts on larger screens.

plurals
  1. POUIDatePicker not updating UILabel
    primarykey
    data
    text
    <p>I have a UIDatePicker and trying to update a UILabel in realtime based on the date selected by a user. If the user selects one date (say Jan 21st 2012) and then changes their mind to (say March 21st 2013) I want the UILabel to reflect the change.</p> <p>So far, the UILabel just reflects the current date and does not update it's text even after the user has selected another date from the UIDatePicker. I have also searched around pointers to fix this but to no avail. Any help will be appreciated. Thanks.</p> <p>Code so far: .h file, I have</p> <pre><code>@property (strong, nonatomic) IBOutlet UILabel *entryDateSetLabel; @property (strong, nonatomic) IBOutlet UIDatePicker *entryDateSelected; - (IBAction)datePickerDateChanged:(id)sender; </code></pre> <p>the datePickerDateChanged is hooked up to the value changed event for the date picker</p> <p>the .m file,</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; self.entryDateSelected = [[UIDatePicker alloc] init]; [self.entryDateSelected addTarget:self action:@selector(datePickerDateChanged:) forControlEvents:UIControlEventValueChanged]; } - (IBAction)datePickerDateChanged:(id)sender { NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init]; [outputFormatter setDateFormat:@"MMMM d, yyyy"]; NSString *entryDateInString = [outputFormatter stringFromDate:self.entryDateSelected.date]; [[self entryDateSetLabel] setText: entryDateInString]; } </code></pre> <p>Screenshots</p> <p><img src="https://i.stack.imgur.com/8QcA8.png" alt="enter image description here"> <img src="https://i.stack.imgur.com/6W3hH.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload