我有 splitView Controller ,默认情况下 rootViewController 作为表格我在 rootViewController 中放置了一个按钮我希望当单击该按钮时它应该将 subView 添加到 rootViewController 但它应该覆盖整个屏幕 lighbox 或我们打开 html 的弹出窗口,它应该在 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];
}
最佳答案
你有两个解决方案。
解决方案 1:
尝试将 View 添加到窗口。
要覆盖整个 View ,您必须将 subview 的尺寸指定为
CGRect subViewBounds = [[UIScreen mainScreen] bounds];
UIView*subView=[[UIView alloc]initWithFrame:subViewBounds];
[self.view.window addSubview:subView] ;
尝试根据它调整 subview 的内容(如标签、按钮等)。
解决方案 2:
创建一个新 View ,如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] ;
关于ios - 如何在 UISplitViewController 中向 Root View Controller 添加新的 subview ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17608565/