I need some help related to iOS application
On clicking the button I added a DatePicker programmatically and now I am not able to remove the view this is my code
I also tried to put the date in label dateLabel but it shows some run time error because it is not a string format I tried some other method also like NSDateFormatter but I am not getting the proper result
-(IBAction)date:(id)sender{
UIDatePicker *datePicker=[[UIDatePicker alloc]initWithFrame:CGRectMake(420, 320, 300, 500)];
[datePicker addTarget:self action:@selector(Pick:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:datePicker];
NSData *date=[datePicker date];
NSLog(@"%@",date);
dateLabel.text=date;
}
-(void)Pick:(id)sender{
[datePicker removeFromSuperview];
}
Do like this