在我的应用中,我是异步搜索。完成后,我的mapViewController显示位置的引脚。 2秒后,我对listViewController进行模态转换。我像这样设置backgroundcolor:
self.view.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.65];
可以看到它背后的地图。
问题是:在listView出现后不到一秒钟,你可以在它消失之前在后台看到地图一秒钟。我现在在后台看到的是应用程序启动的mainViewController。
它看起来像这样:
不到一秒钟之后:
非常感谢任何帮助/解释。
答案 0 :(得分:1)
您的视图仍然是透明的,但是一旦您的模态控制器位于堆栈的顶部,它背后的视图就会被隐藏。
尝试使用:
yourController.modalPresentationStyle = UIModalPresentationCurrentContext;
[yourController present...];
答案 1 :(得分:1)
This code seems to work. I hope it will help.
-(void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
MKMapView *mapView = [MKMapView new];
[self.view addSubview:mapView];
mapView.frame = self.view.bounds;
UIGestureRecognizer *gestureRecognizer = [UITapGestureRecognizer new];
[gestureRecognizer addTarget:self action:@selector(displayTransparentVC)];
[self.view addGestureRecognizer:gestureRecognizer];
}
-(void)displayTransparentVC
{
UIViewController *vc = [TransparentViewController new];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:vc animated:YES completion:^{
}];
}