# Pragma mark invoke after application loaded-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {NSLog (@ "Loading completed... "); // init window self. window = [[[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds] autorelease]; // Override point for customization after application launch. // input the xib file name to init controller self. viewController = [[[PPSViewController alloc] initWithNibName: @ "PPSViewController" bundle: nil] autorelease]; // setting the root view of Window self. window. rootViewController = self. viewController; // The code below is the same as the above setting with the view effect. // [self. window addSubview: self. viewController. view]; [self. window makeKeyAndVisible]; // view visible return YES ;}
At the same time, we can add a subview to the root view. All controls inherit the UIView;
-(Void) viewDidLoad {[super viewDidLoad]; // set the background of the interface [self. view setBackgroundColor: [UIColor redColor]; CGRect frame = CGRectMake (10,170,300, 50); // use the specified rectangle to create the tag UILabel * lable = [[UILabel alloc] initWithFrame: frame]; lable. text = @ "Hello, I am the added subview"; lable. textColor = [UIColor redColor]; [self. view addSubview: lable];}
The running result is as follows: