Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><img src="https://i.stack.imgur.com/FzTvZ.jpg" alt="enter image description here"></p> <pre><code>-(void)viewDidload { UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button1.frame = CGRectMake(165,165, 135,35); [button1 setTitle:@"Type @" forState:UIControlStateNormal]; [button1 addTarget:self action:@selector(button1) forControlEvents:UIControlEventTouchUpInside]; [s addSubview:button1]; } -(void)button1 { items1 =[[NSMutableArray alloc]initWithObjects:@"H",@"E",@"T",@"K",nil]; myPickerView1 =[[UIPickerView alloc] initWithFrame:CGRectMake(60,80,200,300)]; myPickerView1.transform = CGAffineTransformMakeScale(0.75f, 0.75f); myPickerView1.delegate = self; myPickerView1.dataSource = self; myPickerView1.showsSelectionIndicator = YES; myPickerView1.backgroundColor = [UIColor clearColor]; myPickerView1.tag=1; [myPickerView1 selectRow:1 inComponent:0 animated:YES]; [self.view addSubview:myPickerView1]; } - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView; { return 1; } - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component; { switch (pickerView.tag) { case 1: return [items1 count]; break; case 2: return [items2 count]; break; } return 0; } - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { switch (pickerView.tag) { case 1: return[items1 objectAtIndex:row]; break; case 2: return[items2 objectAtIndex:row]; break; } return 0; } -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { switch (pickerView.tag) { case 1: { [button1 setTitle:[items1 objectAtIndex:row] forState:UIControlStateNormal]; } break; case 2: { [button2 setTitle:[items2 objectAtIndex:row] forState:UIControlStateNormal]; }break; } pickerView.hidden = YES; } </code></pre>
 

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