Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>@Madhup's code lead me in the general direction I wanted when I searched for the horizontal <code>UIPickerView</code> but I then realized the question asked wasn't really addressed so for anyone who was looking for a more suitable answer to the left-to-right rotation. The code in the answers I'd read were all to enable left-to-right swiping, causing the picker to push the labels/rows with higher values to the left of the view. Any ways here's my contribution:</p> <p>In the <code>viewDidLoad</code> method:</p> <pre><code> yourPickerView.frame = frame; yourPickerView.transform = CGAffineTransformMakeRotation(4.71238898); //Instead of rotating clockwise 90° we're rotating 90° counterclockwise. 4.71238898 being ≈270° in radians. [self.view addSubview:self.picker]; self.yourPickerView.delegate = self; self.yourPickerView.dataSource = self; self.yourPickerView.showsSelectionIndicator = YES; self.yourPickerView.userInteractionEnabled = YES; </code></pre> <p>The <code>pickerView</code>'s method:</p> <pre><code> -(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{ UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 20, 20)] autorelease]; yourLabel.transform = CGAffineTransformMakeRotation(1.57079633); //Instead of rotating counterclockwise 90° we're rotating 90° clockwise 1.57079633 being ≈90° in radians. yourLabel.font = [UIFont fontWithName:@"System-Bold" size:18]; //Your font here. yourLabel.text = @"yourLabel's text"; //or like me [NSString stringWithFormat:@"%@, [yourArray objectAtIndex:row]] yourLabel.backgroundColor = [UIColor clearColor]; return label; } </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. 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