0
我想用下面的代碼在我使用故事板的地方看到視圖,但是我沒有製作uiviewcontroller的場景初始視圖控制器。 這是我在我的AppDelegate的didFinishLaunchingWithOption中編寫的代碼。將UIViewcontroller的視圖添加到UIWindow中並不顯示
UIWindow* window = [UIApplication sharedApplication].keyWindow;
abcViewController *controller = [[abcViewController alloc]init];
UIView *redView = [[UIView alloc] initWithFrame: CGRectMake ([[UIScreen mainScreen] bounds].origin.x+30, [[UIScreen mainScreen] bounds].origin.y+30, 260, 400)];
[redView setBackgroundColor:[UIColor redColor]];
UIView *greenView = [[UIView alloc] initWithFrame: CGRectMake (redView.frame.origin.x + 10.0f, redView.frame.origin.y + 10.0f, 180, 320)];
[greenView setBackgroundColor:[UIColor greenColor]];
[redView addSubview:greenView];
[controller.view addSubview:redView];
window.rootViewController = controller;
[window makeKeyAndVisible];
return YES;
大感謝你.... !!!!!!!!!!!!!!!!! – Saty