Note that there are some explanatory texts on larger screens.

plurals
  1. POInitial and place an UIButton in an UIActionSheet with an UIPickerView
    text
    copied!<p>I am implementing picker by <a href="https://stackoverflow.com/questions/1262574/add-uipickerview-a-button-in-action-sheet-how">Add UIPickerView &amp; a Button in Action sheet - How?</a>. I tried to replace the UISegmentedControl with a UIButton but it does not working. Could someone remind me why UIButton cannot be shown here?</p> <p>Thank you.</p> <pre><code>- (IBAction) makeButtonPressed: (id) sender; { UIActionSheet *actionSheet = [[UIActionSheet alloc] init]; [actionSheet setTitle:@"Select Make"]; [actionSheet setActionSheetStyle:UIActionSheetStyleBlackOpaque]; UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 44, 0, 0)]; pickerView.dataSource = self; pickerView.delegate = self; pickerView.showsSelectionIndicator = YES; [actionSheet addSubview:pickerView]; // UISegmentedControl *doneButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Done"]]; // doneButton.momentary = YES; // doneButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f); // doneButton.segmentedControlStyle = UISegmentedControlStyleBar; // doneButton.tintColor = [UIColor blackColor]; // [doneButton addTarget:self action:@selector(makeDone:) forControlEvents:UIControlEventValueChanged]; // [actionSheet addSubview:doneButton]; UIButton *doneButton = [[UIButton alloc] init]; doneButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f); [doneButton addTarget:self action:@selector(makeDone:) forControlEvents:UIControlEventValueChanged]; [actionSheet addSubview:doneButton]; [actionSheet showInView:[[UIApplication sharedApplication] keyWindow]]; [actionSheet setBounds:CGRectMake(0, 0, 320, 460)]; } </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