我想展示一个不会使其背后的内容变暗的模态视图控制器。只需使用标准的 presentViewController。只是将视图控制器的子视图添加到父视图会导致问题。
问问题
623 次
3 回答
1
尝试这个:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// remove the dimming view if needed, when this view controller will appear as modal
id <UIViewControllerTransitionCoordinator> transitionCoordinator = self.transitionCoordinator;
if (transitionCoordinator.presentationStyle != UIModalPresentationNone) {
for (UIView *transitionContainerSubview in transitionCoordinator.containerView.subviews) {
if ([NSStringFromClass([transitionContainerSubview class]) isEqualToString:@"UIDimmingView"]) {
transitionContainerSubview.hidden = YES;
}
}
}
}
于 2017-02-27T11:02:49.723 回答
0
最好的办法是将视图添加为子视图而不是模态视图控制器。我不知道你的特殊用途,但从它的声音来看,逻辑应该在同一个控制器中。
myControllerThatWasModal.view.layer.opacity = 0.0f;
myControllerThatWasModal.view.hidden = YES;
[self.view addSubview:myControllerThatWasModal.view];
[UIView animateWithDuration:1.0 animations:^{
myControllerThatWasModal.view.layer.opacity = 1.0f;
}];
这是从内存中编写的,因此请原谅任何错误,而且为了使其正常工作,您需要在它将覆盖的视图控制器中拥有一个“模态”视图控制器的实例。
于 2013-06-05T22:16:41.517 回答
0
看看UIModalPresentationStyle
也许?
typedef NS_ENUM(NSInteger, UIModalPresentationStyle) {
UIModalPresentationFullScreen = 0,
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
UIModalPresentationPageSheet,
UIModalPresentationFormSheet,
UIModalPresentationCurrentContext,
#endif
};
您可以setModalPresentationStyle:
在调用presentViewController:animated:completion:
.
于 2013-06-05T15:35:37.690 回答