I am using Xcode 4.
I have DatePicker Component.
It is taking the Default date which is set in IB's Date to highlight and select the date...
I want to set the current date in date picker to be selected...
Not working setDate Method...
开发者_JAVA百科- (void)viewDidLoad
{
[super viewDidLoad];
[ddlDatePicker setDate:[NSDate date]];
NSLog(@"-%@-",[NSDate date]);
//NSLog is showing me the current date..Today's Date...
//But ddlDatePicker is setted to the date on the day on which I created the date
//Picker...Or You can say date field in the DatePicker's IB Properties..
![enter image description here][1]
}
You have not connected with outlet
your ddlDatePicker
, so you haven't got reference to that object and couldn't manage it.
Open IB and connect this UIDatePicker
with your variable in appropriate controller.
Try this in viewWillAppear rather than viewDidLoad. Also, ensure ddlDatePicker is not nil:
NSLog(@"%@", ddlDatePicker);
精彩评论