zoukankan      html  css  js  c++  java
  • Iphone SDK ActionSheet 在当前窗口弹出时间选择

    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];

    }


  • 相关阅读:
    java IO流之详细总结
    位运算了解与复习多线程
    java 常见面试题总结(一)
    复习集合框架
    【面试题】java中高以上必会技能
    python-项目流程分析及优化查询方法
    python-day97--django-ModelForm
    python-day97--git协同开发
    python-day96--git版本控制
    python-day91--同源策略与Jsonp
  • 原文地址:https://www.cnblogs.com/likwo/p/1757838.html
Copyright © 2011-2022 走看看