Подтвердить что ты не робот

Как отклонить лист действий

Я использовал этот код, чтобы показать uipicker в uiaewsheet, но когда я нажимаю кнопку закрытия, я хочу удалить лист действия из представления. поэтому какой должен быть код для удаления вида формы ActionSheet.

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];

[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

CGRect pickerFrame = CGRectMake(0, 40, 0, 0);

pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
pickerView.showsSelectionIndicator = YES;
pickerView.dataSource = self;
pickerView.delegate = self;

[actionSheet addSubview:pickerView];
[pickerView release];

UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]];
closeButton.momentary = YES; 
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:closeButton];
[closeButton release];

[actionSheet showInView:self.view];//[UIApplication mainWindow]];

[actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
 return false;
}
4b9b3361

Ответ 1

Все, что вам нужно сделать, это отпустить ActionSheet, который вы можете сделать с помощью dismissWithClickedButtonIndex:animated:

Ответ 2

Добавление этого метода сработало для меня:

    -(void) dismissActionSheet:(id)sender {
        UIActionSheet *actionSheet =  (UIActionSheet *)[(UIView *)sender superview];
        [actionSheet dismissWithClickedButtonIndex:0 animated:YES];
    }

Ответ 3

проблема с областью действия.

используется [actionSheet dismissWithClickedButtonIndex:0 animated:YES];