Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I make an "infinite" UIPickerView?
    primarykey
    data
    text
    <p>I have a picker view where the user is entering a time. When they scroll down to hour 23, I want hour zero to appear as the next item, and the sequence to re-start. How can I achieve this?</p> <p>Here is my current picker view data source: </p> <pre><code>- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 3; } - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { NSArray *sectionContents = [[self dataForDatapickerRows] objectAtIndex:component]; NSInteger rows = [sectionContents count]; NSLog(@"component %d rows is: %d",component,rows); return rows; } - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { self.dataPickerInstance.backgroundColor=[UIColor whiteColor]; return ([[[self dataForDatapickerRows ]objectAtIndex:component] objectAtIndex:row]); } - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { if(component==0) { [self setHou:(NSInteger*)[[[self dataForDatapickerRows ]objectAtIndex:component] objectAtIndex:row]]; } else if(component==1) { [self setMinut:(NSInteger*)[[[self dataForDatapickerRows ]objectAtIndex:component] objectAtIndex:row]]; } else if(component==2) { [self setSecon:(NSInteger*)[[[self dataForDatapickerRows ]objectAtIndex:component] objectAtIndex:row]]; } NSLog(@"%@",[[[self dataForDatapickerRows ]objectAtIndex:component] objectAtIndex:row]); } - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{ UILabel* tView = (UILabel*)view; if (!tView){ tView = [[UILabel alloc] init]; [tView setFrame:CGRectMake(0, 0, 90,60)]; tView.self.textColor=[UIColor whiteColor]; tView.minimumFontSize = 80; tView.textAlignment=UITextAlignmentCenter; tView.adjustsFontSizeToFitWidth = YES; tView.autoresizesSubviews=YES; tView.font = [UIFont boldSystemFontOfSize:40]; tView.backgroundColor = [UIColor blackColor]; //tView.highlightedTextColor=[UIColor greenColor]; // factLabel.frame = CGRectMake(factLabel.frame.origin.x, factLabel.frame.origin.y, factLabel.frame.size.width, lLabelSIze.height); // // Setup label properties - frame, font, colors etc } // Fill the label text here tView.text=[[[self dataForDatapickerRows ]objectAtIndex:component] objectAtIndex:row]; return tView; } </code></pre> <p><img src="https://i.stack.imgur.com/unXIm.png" alt="enter image description here"></p>
    singulars
    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. 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