zoukankan      html  css  js  c++  java
  • 【实战】如何实现滚轮时间的显示

    (高级控件)拾取器

    PS:无论是UIPickerView还是UIDatePicker,都需要设置成IBOutlet类型。

    按钮的事件类型为:Touch Up Inside

    - (IBAction)buttonPressed:(id)sender{

      NSDate *selectedTime = [UIDatePicker date];

      NSFormatter *dateFormatter = [[NSFormatter alloc]init];

      [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

      NSString *selectedTimeString = [dateFormatter stringFromDate:selectedTime];

      NSString *message = [[NSString alloc]initWithFormat:@"The date and time you selected is: %@",selectedTimeString];

      UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"shijian" message:message

                                                                        delegate:nil  cancelButtonTitle:@"Cancel" otherButtonTitles:nil];

      [alertView show]; 

    }

    -(void)viewDidLoad{

      [super viewDidLoad];

      NSDate *now = [NSDate date];

      [datePicker setDate:now animated:NO]; //设定日期拾取器的时间,animated:YES是实现动画效果,在初始化时候滚轮滚动到当前日期。

    }

  • 相关阅读:
    5. Longest Palindromic Substring
    24. Swap Nodes in Pairs
    23. Merge k Sorted Lists
    22. Generate Parentheses
    21. Merge Two Sorted Lists
    20. Valid Parentheses
    19. Remove Nth Node From End of List
    18. 4Sum
    17. Letter Combinations of a Phone Number
    14. Longest Common Prefix
  • 原文地址:https://www.cnblogs.com/ejllen/p/3722896.html
Copyright © 2011-2022 走看看