UIAlertController を使用して、ピッカー、キャンセル、完了ボタンのあるビューを表示する必要があります。ここに私が書いたコードがあります:
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:alertAction];
[alertController.view addSubview:pickerView];
[alertController.view addSubview:cancelBtn];
[alertController.view addSubview:doneBtn];
[alertController.view setBounds:CGRectMake(0, 180, self.view.frame.size.width, 400)];
これは、現在のView Controllerメソッドを呼び出す方法です。
UIPopoverPresentationController *popover = alertController.popoverPresentationController;
if (popover)
{
popover.sourceRect = CGRectMake(0, 0, 320, 550);
popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
}
[self presentViewController:alertController animated:YES completion:nil];
アラート コントローラー画面が画面に表示された後、キャンセル ボタンと完了ボタンをタップできず、画面のどこでもタップできません。この問題を解決するために私を助けてください。
設定の境界がない場合、キャンセル ボタンと完了ボタンがページの下部に表示されます。
alertcontroller に境界を設定すると、適切なビューが表示されますが、何も選択できません。