[self.view addSubview:({ UILabel *label = [[UILabel alloc] init]; label.text = @"hello...view.backgroundColor = [UIColor redColor]; view.frame = CGRectMake(100, 100, 100, 100); [self.view addSubview...; [tabbarController setViewControllers:@[controller1,controller2,controller3,controller4]]; self.window.rootViewController...[tabbarController setViewControllers:@[controller1,controller2,controller3,controller4]]; self.window.rootViewController...= tabbarController; [self.window makeKeyAndVisible]; return YES; } ?
mainScreen].bounds]; //创建窗口的根控制器,并且赋值 UIViewController *rootVc = [[UIViewController alloc]init]; self.window.rootViewController...[self.window addsubview:rootVc.view];可直接将控制器的view添加到UIWindow中,并不理会它对应的控制器,但是这种方法违背了MVC原则,当我们需要处理一些业务逻辑的时候就很麻烦了...([self.window addsubview:rootVc.view];没有设置根控制器,所以不能跟着旋转)。 设置根控制器可以将对应界面的事情交给对应的控制器去管理。...UIViewController *vc = [stroyboard instantiateViewControllerWithIdentifier:@"red"]; // 设置窗口的根控制器 self.window.rootViewController...initWithNibName:@"VC" bundle:nil]; //vc.view.backgroundColor = [UIColor redColor]; self.window.rootViewController
:self.advertisingView]; [self addSubview:self.advertisingJumpButton]; [self addSubview...UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window...= [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor =...self.window.rootViewController = adviewcontroller ; [self.window makeKeyAndVisible]; [adviewcontroller.adverView...startplayAdvertisingView:^(AdvertisingView * adverview) { // 更换根控制器 self.window.rootViewController
self.tabBarController.viewControllers = @[navFirst, navSecond, navThird, navFourth, navFifth]; self.window.rootViewController...= self.tabBarController; //将根控制器的视图加到应用程序的主窗口 [self.window addSubview: self.tabBarController.view
= [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window.backgroundColor = [...UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; self.window.rootViewController...UIControlEventTouchUpInside]; [btn setTitle:@"开始" forState:UIControlStateNormal]; btn.tag = 1; [self.view addSubview...UIControlEventTouchUpInside]; btn2.tag = 2; [btn2 setTitle:@"结束" forState:UIControlStateNormal]; [self.view addSubview...delegate.unityWindow.frame = CGRectMake(0, 0, 100, 200); if (btn.tag == 1) { [self.view addSubview
mainScreen].bounds]; //创建跟控制器 UIViewController *VC = [[UIViewController alloc] init]; //加到窗口的跟控制器中 self.window.rootViewController...= VC; //把控制器的View加到窗口中,,不加到跟控制器中也可以显示 //[self.window addSubview:rootVc.view]; //显示窗口 //[self.window...makeKeyWindow];//设为主窗口 [self.window makeKeyAndVisible];//设为主窗口且显示 //self.window.hidden = NO;//只显示 窗口不能显示的原因...UIViewController *rootVc = [storyboard instantiateInitialViewController]; // 3.设置窗口的根控制器,并且显示窗口 self.window.rootViewController...为控制器 UIViewController *rootVc = [[UIViewController alloc] initWithNibName:@"VC" bundle:nil]; self.window.rootViewController
相同,位置为(0,0) mainController.view.frame=self.window.bounds; //设置此控制器为window的根控制器 self.window.rootViewController...initWithFrame:passwordRect]; _password.borderStyle=UITextBorderStyleRoundedRect; [self.view addSubview...self action:@selector(login:) forControlEvents:UIControlEventTouchUpInside];//添加点击事件 [self.view addSubview...UIView就是指界面可见的控件元素,所有的控件最终都继承自UIView,UIView中还可以添加其他UIView(通过addSubView方法); 在一个iOS应用中必须有一个主窗口UIWindow(...,这个控制器距离UIWindow是最近的;设置一个控制器为根控制器和直接通过addSubView添加控制器的视图(view属性)到window并不完全一样(例如如果仅仅添加控制器视图那么应用虽然可以显示但是不支持旋转
kIsGuide]]) { [CommonUtils saveStrValueInUD:@"1" forKey:kGuide]; // 欢迎页置为rootViewController self.window.rootViewController...比如,获取APP的keyWindow并往上添加视图的代码: [[UIApplication sharedApplication].keyWindow addSubview:self.signView];...比如,为设置rootViewController代码: self.window.rootViewController = customTabBarVC;//AppDelegate.m里面 3)....; self.window.hidden = YES; [self.window.rootViewController dismissViewControllerAnimated:YES...FFDropDownMenuView.m文件中有这样一段代码: UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow; [keyWindow addSubview
addsubview:vc.view]; (2)设置uiwindow的根控制器,自动将rootviewcontroller的view添加到window中,负责管理rootviewcontroller...的生命周期 [self.window.rootviewcontroller=vc]; 两个方法的区别: 以后的开发中,建议使用(2).因为方法(1)存在一些问题,比如说控制器上面可能由按钮,需要监听按钮的点击事件...NSLog(@“%@“,self.window.rootviewcontroller); 有storyboard的项目中的创建过程: 当用户点击应用程序图标的时候,先执行Main函数,执行UIApplicationMain...因为Window有makekeyandvisible这个方法,可以让这个Window凭空的显示出来,而其他的view没有这个方法,所以它只能依赖于Window,Window显示出来后,view才依附在Window...alloc] initWithFrame:CGRectMake(10,10,100,40)]; tx2.borderStyle= UITextBorderStyleRoundedRect; [self.w2addSubview
encoding:NSUTF8StringEncoding error:nil]; //运行js文件 [JPEngine evaluateScript:script]; self.window... = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds]; self.window.rootViewController =... [[ViewController alloc]init]; [self.window addSubview:[self genView]]; [self.window makeKeyAndVisible...(label); self.view().addSubview(view) } }); 除了上面的代码,在ViewController.m...调用类方法:通过类名打点的方式来调用类方法,格式类似如下,括号内为参数传递: UIColor.redColor() 调用实例方法:通过对象打点的方式调用类的实例方法,格式如下,括号内为参数传递: view.addSubview
= window; _secondsCountDown = 0; [window makeKeyAndVisible]; //获取启动图片...action:@selector(skipBtnClick) forControlEvents:UIControlEventTouchUpInside]; [self.aDImgView addSubview...self.aDImgView.tag = 1101; self.aDImgView.backgroundColor = [UIColor redColor]; [self addSubview...addSubview:self]; } return self; } #pragma mark - 点击广告 - (void)activiTap:(UITapGestureRecognizer...TestViewController alloc]init]; vc.view.backgroundColor = [UIColor whiteColor]; [self.window.rootViewController
三、UIView生命周期其他点 layoutSubviews的被调用的时机: addSubview会触发layoutSubviews,比如viewA add viewB,第一次添加A和B的layoutSubviews...的UIView才会调用(程序同一时间只有一个window为keyWindow,可以简单理解为显示在最前面的window为keywindow) Push到下一层的顺序 viewWillDisappear-...addsubview:vc.view]; (2)设置uiwindow的根控制器,自动将rootviewcontroller的view添加到window中,负责管理rootviewcontroller...的生命周期 [self.window.rootviewcontroller=vc]; 4、KeyWindow 当前app可以打开的多个window 如系统状态栏其实就是一个window ,程序启动的时候创建的默认的...window ,弹出键盘也是一个window ,alterView 弹框也是window 。
[UIView animateWithDuration:0.3 animations:^{ [[UIApplication sharedApplication].keyWindow addSubview...nil]; self.frame = self.bigFrame; }else { [self removeFromSuperview]; [self.mySuperView addSubview...默认读取plist里面设置的方向(优先级最高)等同于Xcode Geneal设置里面勾选 Paste_Image.png application window设置的级别次之 application支持所有...NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window...UIInterfaceOrientationMaskPortrait; } 级别最低的是viewcontroller里的设置 如何实现某一个页面屏幕旋转,而其他页面不旋转 首先, - (BOOL)shouldAutorotate 必须在 self.window.rootViewController
CGRect firstFrame = self.window.bounds; BNRHypnosisView *firstView = [[BNRHypnosisView alloc...] initWithFrame:firstFrame]; [self.window addSubview:firstView]; ////////////...////////////////////// self.window.rootViewController = [[UIViewController alloc]init];.../////////////////////////////////////////////////////// self.window.backgroundColor = [UIColor...whiteColor]; [self.window makeKeyAndVisible]; return YES; } 上面加的那句到底是啥意思呢?
property (strong, nonatomic) UnityAppController * unityController; @property (strong, nonatomic) UIWindow *window...action:@selector(hideUnityWindow) forControlEvents:UIControlEventTouchUpInside]; [self.unityWindow addSubview...self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window.backgroundColor...[[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]]; self.window.rootViewController...self.unityController application:application didFinishLaunchingWithOptions:launchOptions]; [self.window
UISplitViewControllerDisplayModePrimaryHidden; //设置代理 self.splitViewController.delegate = self; //设置window...的根控制器 self.window.rootViewController = self.splitViewController; return YES; } 实现分割控制器协议的方法...设置数据源和代理 self.tableView.dataSource = self; self.tableView.delegate = self; [self.view addSubview...; [imageView setImage:[self.imageArrayM objectAtIndex:indexPath.row]]; [detatilVC.view addSubview
NSLog(@" 应用启动完成 "); //延长系统启动屏展示的时长 [NSThread sleepForTimeInterval:2]; self.window = [[UIWindow...alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor whiteColor...]; [self.window makeKeyAndVisible]; self.window.rootViewController = [[UINavigationController...UIVisualEffectView alloc] initWithEffect:effect]; _effectView.frame = CGRectMake(0, 0, self.window.frame.size.width..., self.window.frame.size.height); } [self.window addSubview:_effectView]; // 实现如下代码,
属性,而是在SceneDelegate中,可见AppDelegate不管理window而是交给SceneDelegate。...UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:startVC]; self.window.rootViewController...管理window的方式适配: 打开info.plist文件,删除Application Scene Manifest选项。...UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:startVC]; self.window.rootViewController...UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:startVC]; self.window.rootViewController
[[RCTRootView alloc] initWithBridge:bridge moduleName:module initialProperties:nil]; } [self addSubview...[[ReactView alloc] initWithFrame:[UIScreen mainScreen].bounds module:@"testApp"]; self.window...UIViewController *rootViewController = [UIViewController new]; rootViewController.view = reactView; self.window.rootViewController...= rootViewController; [self.window makeKeyAndVisible]; returnYES; } @end 4.按需加载jsbundle