Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIAlertController禁用屏幕上的所有触摸事件_Ios_Iphone_Ipad_Ios8_Uialertcontroller - Fatal编程技术网

Ios UIAlertController禁用屏幕上的所有触摸事件

Ios UIAlertController禁用屏幕上的所有触摸事件,ios,iphone,ipad,ios8,uialertcontroller,Ios,Iphone,Ipad,Ios8,Uialertcontroller,我必须使用UIAlertController显示带有选择器、取消和完成按钮的视图。以下是我编写的代码: UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertAction *alertAction = [UIAlertActio

我必须使用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)];
这就是我如何调用当前视图控制器方法的方式:

UIPopoverPresentationController *popover = alertController.popoverPresentationController;
       if (popover)
       {
          popover.sourceRect = CGRectMake(0, 0, 320, 550);
          popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
        }
 [self presentViewController:alertController animated:YES completion:nil];
当警报控制器屏幕出现在屏幕上后,我无法点击取消和完成按钮以及屏幕上的任何位置。请帮我解决这个问题

如果没有设置边界,“取消”和“完成”按钮显示在页面底部:

每当我将边界设置为alertcontroller时,我都可以看到正确的视图,但无法选择任何内容:

我敢打赌你的界限是不正确的。所以这一行:

[alertController.view setBounds:CGRectMake0,180,self.view.frame.size.width,400]

正在将视图边界设置为从180开始

编辑:根据以下注释,如果要设置按钮位置,应修改按钮框架,而不是alertview边界


请记住,框架是根据父视图坐标系的视图位置。边界是与其自身坐标系相关的视图限制。

我已经验证过了。边界宽度不是0。请在presentViewController完成时添加一个块,以打印视图边界和大小。未检测到单击的问题通常与bounds.Added有关。我设定的值被打印出来了。你为什么从180开始?请注意,边界是根据自己的视图坐标系定义的。很抱歉坚持,这个问题通常与边界有关。每当我评论并运行边界行时,我都可以点击“取消”和“完成”按钮。但这些都出现在页面底部。如果是这样的话,对用户的选择将是一个问题。所以我把它设为180,你知道了吗?