博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

1.首先实现UIActionSheetDelete协议

2.

    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:nil destructiveButtonTitle:nil otherButtonTitles:@"Set", nil];
    [actionSheet showInView:self.view];
    UIDatePicker *datePicker = [[[UIDatePicker alloc] init] autorelease];
    datePicker.tag = 101;
   // datePicker.datePickerMode = [(UISegmentedControl *)self.navigationItem.titleView selectedSegmentIndex];
    [actionSheet addSubview:datePicker];

 

3.响应点击 Set后的函数

//根据 buttonIndex的参数的不同,进行处理。

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    UIDatePicker *datePicker = (UIDatePicker *)[actionSheet viewWithTag:101];
    NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
    formatter.dateFormat = @"MM/dd/YY h:mm a";

    NSString *timestamp = [formatter stringFromDate:datePicker.date];

    //显示时间的变量

    [(UILabel *)[self.view viewWithTag:103] setText:timestamp];
    [actionSheet release];

}

 


 

posted on 2010-06-13 15:48  Likwo  阅读(1841)  评论(0编辑  收藏  举报