Tengo un UIPickerView y necesito que se muestre dentro de una UIActionSheet en iPad (funciona muy bien en iPhone, no en iPad).Agregar un UIPickerView dentro de UIActionSheet en iPad
Tengo un botón en la vista cuando hago clic en ejecuto el siguiente código:
- (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];
}
// El delegado del origen de datos y funciones PickerView:
// 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";
}
pero cuando el cambio lo anterior código para agregar el PickerView dentro de un actionSheet, ¡Muestra solo el encabezado de la hoja de acción pero sin PickerView dentro de él!
El código modificado de la siguiente manera:
- (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];
}
Cuando cambié el selector InitLine a 'UIPickerView * selector = [[UIPickerView alloc] initWithFrame: CGRectMake (0,0,320,469)];' Ahora puedo ver una parte muy pequeña del PickerView dentro de la Hoja de Acción pero se muestra la hoja de acción como un cuadrado muy pequeño, ¿cómo puedo hacerlo más grande, estoy tratando de cambiar su ancho y alto, pero parece que no funciona! –
Intenta establecer el cancelButtonTitle en algunos NSString para ver si el tamaño cambia. –
¡Asqueroso, en su lugar usaré un 'UIPopoverController' con un' UITableViewController'! .. ¡Gracias de cualquier manera! –