To use this controller, designed to be used as a drill-down in a Navigation-based App, all you have to do is create an instance of the class, and set that instance's delegate to self, and then set the date to be displayed when it is first shown, like so:
DateViewController *controller = ;
controller.delegate = self;
controller.date = theDateToBeEdited;
;
;Then, implement this delegate method:
- (void)takeNewDate:(NSDate *)newDate
{
myObject.date = newDate;
}Now, when the drill-down controller is dismissed, if the user pressed the Save button, that takeNewDate: method will get called with the new value, and all you have to do is stick the new date back into your data model. The controller class is self-contained, and there's no need to edit the controller class at all (though feel free to expand on it if you want). If you want to customize the appearance of the date picker, you can use the controller's datePicker property, for example, to change the date picker's mode:
controller.datePicker.datePickerMode = UIDatePickerModeDateAndTime;Here's the date picker class:
DateViewController.h
/*
DateViewController.h
*/
DateViewController.m
/*
DateViewController.m
*/
0 comments:
Post a Comment