我正在使用 presentModalViewController 尝试在其他一些视图之上显示 UIView。我从控制器 1 调用 presentModalViewController。我正在尝试显示来自 controller2 的视图。
从控制器 1 我调用控制器 2,如下所示:
- (void) someButtonPressed: (id)sender
{
MyController* controller2 = [ [ MyController alloc ] initWithNibName:nil bundle:nil ];
[self presentModalViewController:controller2 animated:YES];
//[self presentViewController:controller2 animated:NO completion:nil ];
}
然后在controller2中我这样做:
- (void)viewDidLoad
{
[super viewDidLoad];
if (YES){
UIWindow* keyWindow = [[UIApplication sharedApplication] keyWindow];
UIView* master = (UIView*)[keyWindow viewWithTag:100]; // Master is the entire app, but always oriented so top left corner is 0,0.
UIView* newView = [ [ UIView alloc ] initWithFrame:CGRectMake(100, 100, 400, 400) ];
[self setView:newView ];
self.view.backgroundColor = [ UIColor clearColor ];
}
}
问题是第一个控制器中的任何内容都没有显示出来。我希望以前的视图保持可见。有没有办法让第二个控制器的视图不可见?我想这样做的原因是因为我希望第二个控制器/视图显示一个透明层,该层将捕获所有触摸事件,而无需它们通过控制器 1 管理的视图。
非常感谢。