Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have a custom time picker (UIPickerView), for which the delegate looks like this:</p> <pre><code>-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{ return 4; // it's with am/pm in my case } -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{ /// 18000 is divisible with 12, 24 (for the hour) and 60 (for the minutes and seconds) /// it can still get to the end.. but will need a lot of scrolling /// I set the initial value between 9000 and 9060 if (component==0) { // hour return 18000; } if (component==3) { // am/pm return [_datasource count]; } // seconds and minutes - could use 45000 so it repeats the same number of time as the hours return 18000; } -(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{ if (component==3) { // am/pm return [_datasource objectAtIndex:row]; } if (component==0) { // hour return [NSString stringWithFormat:@"%d", row%12]; } return [NSString stringWithFormat:@"%02d", row%60]; } -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{ if (component==3) { // am/pm if (row==0&amp;&amp;_h&gt;11) { _h-=12; } if (row==1&amp;_h&lt;12) { _h+=12; } } else if(component==0){ _h=row%12; if ([self selectedRowInComponent:3]==1) { // handle am/pm _h+=12; } } else if(component==1){ _m=row%60; } else if(component==2){ _s=row%60; } } -(CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component{ // set the size for components if (component&lt;3) { return 50; } return 70; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload