Я хочу отобразить UIActionSheet поверх UIAlertView. Но в соответствии с приведенным ниже кодом он будет скрыт от UIAlertView. (См. Ниже снимок экрана) Как показать UIActionSheet поверх UIAlertView в объекте c
Сначала я показываю пользовательский UIAlertView и, когда пользователь нажимает Units, затем отображает таблицу UIActionSheet. Но он скрыт от UIAlertView. Ниже приведен мой код.
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if (actionSheet.tag == 2) {
return;
}
if (actionSheet.tag == 1 && (int)buttonIndex == 4) {
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 310, 60)];
UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(5,0,100,25)];
label1.text = @"Dimensions:";
[v addSubview:label1];
UITextField *textField1 = [[UITextField alloc] initWithFrame:CGRectMake(100,0,60,25)];
textField1.borderStyle = UITextBorderStyleRoundedRect;
textField1.placeholder = @"Width";
textField1.keyboardAppearance = UIKeyboardAppearanceAlert;
[textField1 setValue:[UIFont fontWithName: @"San Francisco" size:12] forKeyPath:@"_placeholderLabel.font"];
textField1.delegate = self;
[v addSubview:textField1];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(172,0,25,25)];
label.text = @"X";
[v addSubview:label];
UITextField *textField3 = [[UITextField alloc] initWithFrame:CGRectMake(195,0,60,25)];
textField3.placeholder = @"Height";
textField3.borderStyle = UITextBorderStyleRoundedRect;
textField3.keyboardAppearance = UIKeyboardAppearanceAlert;
[textField3 setValue:[UIFont fontWithName: @"San Francisco" size:12] forKeyPath:@"_placeholderLabel.font"];
textField3.delegate = self;
[v addSubview:textField3];
UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(5,30,50,25)];
label2.text = @"Units:";
[v addSubview:label2];
UITextField *textField4 = [[ReadOnlyTextField alloc] initWithFrame:CGRectMake(100,30,155,25)]; //145
textField4.placeholder = @"-- Select an Unit --";
textField4.borderStyle = UITextBorderStyleRoundedRect;
textField4.keyboardAppearance = UIKeyboardAppearanceAlert;
[textField4 setValue:[UIFont fontWithName: @"San Francisco" size:12] forKeyPath:@"_placeholderLabel.font"];
[textField4 addTarget:self action:@selector(selectUnit:) forControlEvents:UIControlEventTouchDown];
textField4.delegate = self;
[v addSubview:textField4];
av = [[UIAlertView alloc] initWithTitle:@"Dimensions" message:@"" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Download", nil];
[av setValue:v forKey:@"accessoryView"];
[av show];
}
-(void)selectUnit:(id)sender
{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select an option" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
actionSheet.tag = 2;
[actionSheet addButtonWithTitle:@"Pixels"];
[actionSheet addButtonWithTitle:@"Inches"];
[actionSheet addButtonWithTitle:@"Centimetres"];
[actionSheet addButtonWithTitle:@"Millimetres"];
[actionSheet addButtonWithTitle:@"Cancel"];
[actionSheet showInView:self.view]; //[UIApplication sharedApplication].keyWindow.rootViewController.view
}
Так как я могу отобразить UIActionSheet поверх настроенной UIAlertView ????
Можете ли вы объяснить точный поток вашего кода? Я думаю, что сначала вы вызвали UIActionSheet, тогда ответ на UIActionsheet - это UIAlertView, а в действии UIAlertView вы хотите показать новый UIActionSheet. –
@SiddheshMhatre Сначала я открываю UIActionSheet, а затем выбираю опцию. при выборе опции он будет открыт настраиваемый UIAlertView. После этого, когда я выбираю настраиваемое текстовое поле в UIAlertView (поле единицы), снова откройте таблицу UIActionSheet. Этот UIActionSheet скрыт от предыдущего UIAlerView (см. Прикрепленное изображение). –