Search code examples
iosdateuipickerviewuiactionsheet

ActionSheetPickerClass , iOS


I am using this class , https://github.com/TimCinel/ActionSheetPicker to choose current date in my application. The problem is that i would also like to choose a time (hour and minutes) with a picker like this. Can anyone help me customize the class or know any other class that does that? Thank you!


Solution

  • I never used, just saw the source code now. But from here:

      _actionSheetPicker = [[ActionSheetDatePicker alloc] initWithTitle:@"" datePickerMode:UIDatePickerModeDate selectedDate:self.selectedDate target:self action:@selector(dateWasSelected:element:) origin:sender];
    

    You need to define your datePickerMode:UIDatePickerModeDate so you need to check what types the UIDatePickerMode accepts. So:

    typedef enum {
        UIDatePickerModeTime,           // Displays hour, minute, and optionally AM/PM designation depending on the locale setting (e.g. 6 | 53 | PM)
        UIDatePickerModeDate,           // Displays month, day, and year depending on the locale setting (e.g. November | 15 | 2007)
        UIDatePickerModeDateAndTime,    // Displays date, hour, minute, and optionally AM/PM designation depending on the locale setting (e.g. Wed Nov 15 | 6 | 53 | PM)
        UIDatePickerModeCountDownTimer  // Displays hour and minute (e.g. 1 | 53)
    } UIDatePickerMode;
    

    Select the one you want.