使用UIActionSheet 弹出UIDatePicker

-(IBAction)SelectValue:(id)sender
{
    NSString *title = UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation) ? @"\n\n\n\n\n\n\n\n\n" : @"\n\n\n\n\n\n\n\n\n\n\n\n" ;
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:@"确定" destructiveButtonTitle:nil otherButtonTitles:nil];
    
    

    
    [actionSheet showInView:self.view];
    UIDatePicker *datePicker = [[[UIDatePicker alloc] init] autorelease];
    datePicker.tag = 101;
    datePicker.datePickerMode = 1;
    [actionSheet addSubview:datePicker];
  
     [actionSheet showFromTabBar:(UITabBar *)self.tabBarController.view];     
    
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    UIDatePicker *datePicker = (UIDatePicker *)[actionSheet viewWithTag:101];
    NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
    formatter.dateFormat = @"yyyy年 MM月 dd日";
    NSString *timesp = [formatter stringFromDate:datePicker.date];
    TradedateLabel.text =timesp;
    [actionSheet release];
}


你可能感兴趣的:(使用UIActionSheet 弹出UIDatePicker)