Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding a UIPickerView inside UIActionSheet in iPad
    text
    copied!<p>I've a UIPickerView and need to make it show inside a UIActionSheet in iPad (it works very straightforward in iPhone, not in iPad).</p> <p>I've a button on the View when I click on I execute the following code:</p> <pre><code>- (IBAction) buttonPressed:(id)sender { NSLog(@"I am pressed"); UIPickerView* picker = [[UIPickerView alloc] initWithFrame:CGRectMake(100,200,500,500)]; picker.delegate = self; picker.dataSource = self; picker.showsSelectionIndicator = YES; [self.view addSubview:picker]; } </code></pre> <p>// the PickerView delegate and datasource functions:</p> <pre><code>// returns the number of 'columns' to display. - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1; } // returns the # of rows in each component.. - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return 5; } - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { return @"One"; } </code></pre> <p>But When change the above code to add the PickerView inside an actionSheet, <strong>It shows only the header of the ActionSheet but without the PickerView inside it!</strong></p> <p>The modified code as follows:</p> <pre><code>- (IBAction) buttonPressed:(id)sender { NSLog(@"I am pressed"); UIActionSheet* actionSheet = [[UIActionSheet alloc] initWithTitle:@"My PickerView" delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil]; UIPickerView* picker = [[UIPickerView alloc] initWithFrame:CGRectMake(100,200,500,500)]; picker.delegate = self; picker.dataSource = self; picker.showsSelectionIndicator = YES; [actionSheet addSubview:picker]; [actionSheet showFromRect:CGRectMake(0, 0, 320, 469) inView:self.view animated:NO]; } </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