Datepiker control complete implementation code with example in iphone. This complete demo will give you complete source code with code snaps .
devangViewController .h header file
#import "devangViewController.h"
Output:
devangViewController .h header file
#import <UIKit/UIKit.h>devangViewController .m
@interface devangViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UIDatePicker *datepiker_outlet;
- (IBAction)datepiker_select:(id)sender;
@end
#import "devangViewController.h"
@interface devangViewController ()
@end
@implementation devangViewController
@synthesize dateLabel;
@synthesize datepiker_outlet;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"MM/dd/yyyy"];
NSString *formattedDate = [df stringFromDate:datepiker_outlet.date];
dateLabel.text=[NSString stringWithFormat:@"%@" ,formattedDate];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)datepiker_select:(id)sender {
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"MM/dd/yyyy"];
NSString *formattedDate = [df stringFromDate:datepiker_outlet.date];
dateLabel.text=[NSString stringWithFormat:@"%@" ,formattedDate];
}
@end
Output:
Here is the complete source code also.
0 comments:
Post a Comment