Friday, December 6, 2013

empty project added. xib file.

http://www.uplook.cn/kbase-Index-show-view17674.html
According to the article adds. Xib file, and then add a label tags and buttons, controls can be displayed, but can not click on the button. After closing the restart control disappeared, and why?
I use Xcode4.2, there are no new empty project. Xib file, you need to add it manually.
AppDelegate.h file
# Import
@ Interface AppDelegate: UIResponder {

UIWindow * window;
UILabel * lab;

}

@ Property (nonatomic, retain) IBOutlet UIWindow * window;

@ Property (nonatomic, retain) IBOutlet UILabel * lab;
- (IBAction) button: (id) sender;

@ End

AppDelegate.m file
# Import "AppDelegate.h"

@ Implementation AppDelegate
/ / @ Synthesize view;

@ Synthesize window;
@ Synthesize lab;

- (IBAction) button: (id) sender {

lab.text = @ "Hello World!";

}
- (Void) dealloc
{
[Window release];
[Lab release];
[Super dealloc];
}

- (BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]] autorelease];
/ / Override point for customization after application launch.
self.window.backgroundColor = [UIColor orangeColor];
NSLog (@ "I have run");
[Self.window makeKeyAndVisible];
return YES;
}

- (Void) applicationWillResignActive: (UIApplication *) application
{
/ / Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
/ / Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (Void) applicationDidEnterBackground: (UIApplication *) application
{
/ / Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
/ / If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits
.}

- (Void) applicationWillEnterForeground: (UIApplication *) application
{
/ / Called as part of the transition from the background to the inactive state;. Here you can undo many of the changes made on entering the background
}

- (Void) applicationDidBecomeActive: (UIApplication *) application
{
/ / Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (Void) applicationWillTerminate: (UIApplication *) application
{
/ / Called when the application is about to terminate Save data if appropriate See also applicationDidEnterBackground:...
}

@ End


Reply:
Brother, you are here
these operations do not workIn creating the project when trying to choose a single type of

Then you add in those operations in viewController (xib draw well after going to the link can trigger events)

In or achieved only with code
Reply:
UILabel those basic controls must be added to the view, can not be added to the windows, windows can add a variety of view + viewController

Reply:
reference to the second floor of the reply:
UILabel those basic controls must be added to the view, can not be added to the windows, windows can add a variety of view + viewController

Please do not mislead people good. Who's to say your window can not add UILable, only add view.
If the window is compared to the TV screen, view, and other elements of the equivalent figure displayed on the TV. window is fixed, while the view is variable.

You do not show at runtime, because you only create a window. Your xib document does not take effect.
You need to - (BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *) create launchOptions this message window instance commented, not code to create, but to create
by xib
self.window = [[[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]] autorelease];
/ / Override point for customization after application launch.
self.window.backgroundColor = [UIColor orangeColor];

These are all commented above. Try again. (Ensure UIWindow, UILabel with xib connection has been established)

No comments:

Post a Comment