Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd Original Custom View to the Window
    primarykey
    data
    text
    <p>I added my custom view to the window but it doesn't work. I tried to figure it out but it doesn't work well. (I created this project with the empty project template without using storyboards). This screen is supposed to show the red rectangle towards the bottom right corner of the screen.</p> <p><strong>I wanted to add my custom view showing red screen to the window, but it just shows the white screen.</strong></p> <p>AppDelegate.m:</p> <pre><code>// // HypnosisterAppDelegate.m // Hypnosister // // Created by TSH on 12/1/13. // Copyright (c) 2013 TSH. All rights reserved. // #import "HypnosisterAppDelegate.h" #import "HypnosisterViewController.h" #import "HypnosisView.h" @implementation HypnosisterAppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. HypnosisterViewController *test = [[HypnosisterViewController alloc] initWithNibName:@"HypnosisterViewController" bundle:nil]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:test]; self.window.rootViewController = nav; CGRect viewFrame = CGRectMake(16, 24, 10, 15); HypnosisView *view = [[HypnosisView alloc] initWithFrame:viewFrame]; [view setBackgroundColor:[UIColor redColor]]; [[self window] addSubview:view]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; } @end </code></pre> <hr> <p>[edit]</p> <p>I just messed up the ordering.</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; HypnosisterViewController *test = [[HypnosisterViewController alloc] initWithNibName:@"HypnosisterViewController" bundle:nil]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:test]; self.window.rootViewController = nav; CGRect viewFrame = CGRectMake(160, 240, 100, 150); HypnosisView *view = [[HypnosisView alloc] initWithFrame:viewFrame]; [view setBackgroundColor:[UIColor redColor]]; [[self window] addSubview:view]; return YES; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload