Sunday, September 4, 2011

Do you know Objective-c? UIApplication&UIView

Today we will see essential elements that make up all iPhone application and will serve as a base to mount your application (actions and appearance): UIApplication and UIView

I) UIApplication: 
UIApplication is, the entry point of the application, and is responsible for initializing and displaying a UIWindow, uploading this to load the first view (UIView). UIApplication manages the lifecycle of the application, using the UIApplicationDelegate, which manages the events received by the UIApplication. An example of events would start the application, close it, when a call is received while application is running, etc... So the events to handle are:
  • WillChangeStatusBarFrame: It will change the frame of the status bar.
  • DidChangeStatusBarOrientation: Change the orientation of the status bar.
  • WillChangeStatusBarOrientation:duration:It will change the orientation of the status bar and the duration parameter indicates how the animation will last. 
  • AandleOpenURL: Tells the delegate who wants to open a URL.
  • ApplicationDidBecomeActive: When the app is interrupted for whatever reason, will run in time to end this interruption.  
  • ApplicationDidFinishLaunching: Runs when the application has finished loading.
  • ApplicationDidReceiveMemoryWarning: When the device will run out of memory reaches, giving a "second chance" to free up space.
  • ApplicationSignificantTimeCharge: Runs to a significant change in the time during the performance of your application.  
  • ApplicationWillResignActive: Runs to a significant change in the time during the performance of your application.
  • ApplicationWillTerminate: Runs before it goes do idle.
  • ApplicationDidEnterBackground: The application will go into the background but if the application does not have multitasking implemented this method should save the state of the application, freeing the memory as it is on "pause" in the background when the user re-enters be in the sate in which it was but when in this "pause" if the memory the OS needs to close.
  • ApplicationWillEnterForeground: The application returns to the fore.
 II) UIView: 
 For each interface file .xib which has a UIView, will correspond to the handler classes .xib. UIView inherits UIView and will manage everything related to the associated view. UIViewController also manages the life cycle of UIView with the following events:
  • didReceiveMemoryWarning: When the controller receives a notice of memory. 
  • DidRotateFromInterfaceOrientation: Called after the view has rotated. 
  • WillRotateToInterfaceOrientation:duration: Called when the view starts to rotate, the duration indicates how long will it take to rotate.  
  • ViewDidAppear: Called after the view has emerged.  
  • ViewDidDisappear: Called after the view has disappeared.  
  • ViewDidLoad: Called after the view has been loaded into memory. 
  • ViewWillAppear: It is invoked just before the view appears. Is invoked just before the view disappears. 
  • WillAnimateFirstHalfOfRotationToInterfaceOrientation:duration: Runs before the rotation of the firs half of the interface and the duration will last.
  • WillAnimateSecondHalfOfRotationFromInterfaceOrientation:duration: Runs before the rotation of the second half of the interface and the duration will last. 
Now we know the basic operation of a UIView and UIApplication, we will see ViewTableController and ViewTable, which will be useful to develop a set of views to "surf" for our app.

No comments: