1

我有一个视图通过

navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[weakSelf presentViewController:navigationController animated:YES completion:^{}];

唯一的问题是呈现该新视图的“主”视图具有可以触摸的按钮,因为 ModalPresentationFormSheet 没有占据全屏。我想保留这种格式,但在显示模态时防止点击。我知道我可以对每个可能的按钮进行此检查,但我相信还有另一种方法!

    if (![weakSelf presentedViewController]) 

谢谢!

4

2 回答 2

0

您可以将“新视图”作为另一个全屏视图的子视图,并使“父视图”背景颜色清除颜色,以便您也可以看到“主视图”。
现在您无法单击按钮,因为您实际上是在单击“新视图”上的父视图

于 2013-07-11T13:18:20.510 回答
0

一种方法是在托管视图控制器上方但在表单下方放置一个不可见的“防护罩”。

基本上,创建一个背景颜色清晰的空 UIView。在您拨打电话之前,将其作为子视图添加到您的呈现视图控制器:

[weakSelf presentViewController:navigationController animated:YES completion:^{}];

现在,这并不一定意味着这样的解决方案很有品味。也就是说,表单样式并不意味着以这种方式排他性,如果上面安装的 UIView 是清晰的,它可能会令人困惑。因此,您可以减少该视图上的 alpha 值,将其变成一个变暗的屏幕,以帮助用户了解表单是他们当时唯一可以与之交互的东西:

UIView *dimmingScreen = [[UIView alloc] initWithFrame:self.view.bounds];
dimmingScreen.alpha = 0.5; // play with this value to get different degrees of dimming
dimmingScreen.backgroundColor = [UIColor blackColor]; // play with different colors
[self.view addSubview:dimmingScreen]; 

// Now present your form sheet, as you were:
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[weakSelf presentViewController:navigationController animated:YES completion:^{}];

您还希望能够移除调光屏幕,因此最好将其设置为您可以访问的视图控制器属性,以便在需要时移除。

于 2013-07-11T13:20:32.943 回答