0

ピッカー ビューを UIAlertController に追加しましたが、そのタッチはピッカー全体では機能せず、ピッカーの特定の部分でのみ機能しています。これを手伝ってください

このコード:

if (IS_IOS8_AND_UP) {

    UIAlertController * searchActionSheet=[UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];

    [searchActionSheet.view setBounds:CGRectMake(8, 180, self.viewSize.width, sheetHeight)];

// aView.frame=CGRectMake(100, 100, aView.frame.size.width, aView.frame.size.height);

  //yourView represent the view that contains UIPickerView and toolbar

[searchActionSheet.view addSubview:aView]; //[[self topViewController].view addSubview:searchActionSheet.view]; [[self topViewController] presentViewController:searchActionSheet アニメーション:YES 完了:nil];

}
else
{
    _actionSheet = [[UIActionSheet alloc] initWithTitle:paddedSheetTitle delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
    [_actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
    [_actionSheet addSubview:aView];
    [self presentActionSheet:_actionSheet];
    _actionSheet.bounds = CGRectMake(0, 0, self.viewSize.width, sheetHeight);
}

画像を見るここに画像の説明を入力

4

1 に答える 1

0
UIAlertController * searchActionSheet=[UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"" style:UIAlertActionStyleDefault handler:nil]; 
[searchActionSheet addAction:alertAction];
[searchActionSheet addAction:alertAction];
[searchActionSheet addAction:alertAction];
[searchActionSheet addSubview:picker];

上で追加したように、alertAction オブジェクトを alertcontroller に追加します。その後、ピッカーをサブビューとしてアラートコントローラーに追加してみてください。

ビューを調整するために必要な数の alertAction オブジェクトを追加します。それが正しい方法かどうかはわかりませんが、私にとってはうまくいきました。

于 2014-10-28T11:21:54.907 に答える