I use Xcode 4.5 and iOS 6.0, I selected the default single view template from xcode, I just want to add a shortcut to the application window, but I cannot do this. Please correct me.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; self.window.rootViewController = self.viewController; label =[[UILabel alloc] initWithFrame:CGRectMake(100, 100, 200, 20)]; label.text = @"Test"; [label setBackgroundColor:[UIColor whiteColor]]; [self.window addSubview:label]; [self.window bringSubviewToFront:label]; [self.window makeKeyAndVisible]; return YES; }
PS - I want my shortcut to be on top of my ViewController, for example, in a window, so it will always be there, despite the changes in the views presented by the window. I do not want to show only the shortcut.
I got an answer
[self.window.rootViewController.view addSubview:label]
Thanks to everyone for providing pointers.
source share