1

我有一个带有rootViewController的splitView控制器默认情况下我在rootViewController中放置了一个按钮我希望当单击该按钮时它应该将subView添加到rootViewController但它应该覆盖整个屏幕lighbox或我们打开html的弹出窗口,它应该覆盖所有screen 而不仅仅是 splitViewController 中 rootViewController 的 tableArea

-(void)onSettingButtonClick{

  NSLog(@"Working click fine");
  UIView*subView=[[UIView alloc]initWithFrame:CGRectMake(0,10,600,400)];

  subView.backgroundColor=[UIColor greenColor];

  [self.view addSubview:subView];
}

在此处输入图像描述

4

1 回答 1

1

你有两个解决方案。

解决方案 1:

尝试将视图添加到窗口。

要覆盖整个视图,您必须将 subView 的尺寸指定为

CGRect subViewBounds = [[UIScreen mainScreen] bounds];
UIView*subView=[[UIView alloc]initWithFrame:subViewBounds];
[self.view.window addSubview:subView] ;

尝试据此调整子视图的内容(如标签、按钮等)。

解决方案 2:

创建一个新视图,如 backgroundView

CGRect backgroundViewBounds = [[UIScreen mainScreen] bounds];
UIView*backgroundView = [[UIView alloc]initWithFrame:backgroundViewBounds];
[self.view.window addSubview:backgroundView] ;

CGRect subViewBounds = CGRectMake(0,10,600,400) ;
UIView*subView=[[UIView alloc]initWithFrame:subViewBounds];
[backgroundView addSubview:subView] ;
于 2013-07-12T07:25:53.610 回答