Class: UIApplication
- Inherits:
-
UIResponder
- Object
- NSObject
- UIResponder
- UIApplication
Overview
The UIApplication class provides a centralized point of control and coordination for applications running on iOS.
Instance Attribute Summary (collapse)
-
- applicationIconBadgeNumber
The number currently set as the badge of the application icon in Springboard.
-
- applicationState
readonly
The runtime state of the application.
-
- applicationSupportsShakeToEdit
A Boolean value that determines whether shaking the device displays the undo-redo user interface.
-
- backgroundTimeRemaining
readonly
The amount of time the application has to run in the background.
-
- delegate
The delegate of the application object.
-
- idleTimerDisabled
A Boolean value that controls whether the idle timer is disabled for the application.
-
- keyWindow
readonly
The application's key window.
-
- networkActivityIndicatorVisible
A Boolean value that turns an indicator of network activity on or off.
-
- protectedDataAvailable
readonly
A Boolean value indicating whether content protection is active.
-
- scheduledLocalNotifications
All currently scheduled local notifications.
-
- statusBarFrame
readonly
The frame rectangle defining the area of the status bar.
-
- statusBarHidden
A Boolean value that determines whether the status bar is hidden.
-
- statusBarOrientation
The current orientation of the application's status bar.
-
- statusBarOrientationAnimationDuration
readonly
The animation duration in seconds for the status bar during a 90 degree orientation change.
-
- statusBarStyle
The current style of the status bar.
-
- userInterfaceLayoutDirection
readonly
Returns the layout direction of the user interface.
-
- windows
readonly
The application's visible and hidden windows.
Attributes inherited from UIResponder
#inputAccessoryView, #inputView, #undoManager
Class Method Summary (collapse)
-
+ sharedApplication
Returns the singleton application instance.
Instance Method Summary (collapse)
-
- beginBackgroundTaskWithExpirationHandler:
Marks the beginning of a new long-running background task.
-
- beginIgnoringInteractionEvents
Tells the receiver to suspend the handling of touch-related events.
-
- beginReceivingRemoteControlEvents
Tells the application to begin receiving remote-control events.
-
- cancelAllLocalNotifications
Cancels the delivery of all scheduled local notifications.
-
- cancelLocalNotification:
Cancels the delivery of the specified scheduled local notification.
-
- canOpenURL:
Returns whether an application can open a given URL resource.
-
- clearKeepAliveTimeout
Removes a previously installed periodic handler block.
-
- completeStateRestoration
Tells the app that your code has finished any asynchronous state restoration.
-
- enabledRemoteNotificationTypes
Returns the types of notifications the application accepts.
-
- endBackgroundTask:
Marks the end of a specific long-running background task.
-
- endIgnoringInteractionEvents
Tells the receiver to resume the handling of touch-related events.
-
- endReceivingRemoteControlEvents
Tells the application to stop receiving remote-control events.
-
- extendStateRestoration
Tells the app that your code is restoring state asynchronously.
-
- isIgnoringInteractionEvents
Returns whether the receiver is ignoring events initiated by touches on the screen.
-
- openURL:
Opens the resource at the specified URL.
-
- presentLocalNotificationNow:
Presents a local notification immediately.
-
- registerForRemoteNotificationTypes:
Register to receive notifications of the specified types from a provider via Apple Push Service.
-
- scheduleLocalNotification:
Schedules a local notification for delivery at its encapsulated date and time.
-
- sendAction:to:from:forEvent:
Sends an action message identified by selector to a specified target.
-
- sendEvent:
Dispatches an event to the appropriate responder objects in the application.
-
- setKeepAliveTimeout:handler:
Configures a periodic handler for VoIP applications.
-
- setNewsstandIconImage:
Sets the icon of a Newsstand application to an image depicting the current issue of a publication.
-
- setStatusBarHidden:withAnimation:
Hides or shows the status bar, optionally animating the transition.
-
- setStatusBarOrientation:animated:
Sets the application's status bar to the specified orientation, optionally animating the transition.
-
- setStatusBarStyle:animated:
Sets the style of the status bar, optionally animating the transition to the new style.
-
- supportedInterfaceOrientationsForWindow:
Returns the default set of interface orientations to use for the view controllers in the specified window.
-
- unregisterForRemoteNotifications
Unregister for notifications received from Apple Push Service.
Methods inherited from UIResponder
#becomeFirstResponder, #canBecomeFirstResponder, #canPerformAction:withSender:, #canResignFirstResponder, #isFirstResponder, #motionBegan:withEvent:, #motionCancelled:withEvent:, #motionEnded:withEvent:, #nextResponder, #reloadInputViews, #remoteControlReceivedWithEvent:, #resignFirstResponder, #touchesBegan:withEvent:, #touchesCancelled:withEvent:, #touchesEnded:withEvent:, #touchesMoved:withEvent:
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Instance Attribute Details
- (Integer) applicationIconBadgeNumber
The number currently set as the badge of the application icon in Springboard. Set to 0 (zero) to hide the badge number. The default is 0.
- (UIApplicationState) applicationState (readonly)
The runtime state of the application. (read-only) An application may be active, inactive, or running in the background. You can use the value in this property to determine which of these states the application is currently in.
- (Boolean) applicationSupportsShakeToEdit
A Boolean value that determines whether shaking the device displays the undo-redo user interface. The default value is YES. Set the property to NO if you don’t want your application to display the Undo and Redo buttons when users shake the device.
- (NSTimeInterval) backgroundTimeRemaining (readonly)
The amount of time the application has to run in the background. (read-only) This property contains the amount of time the application has to run in the background before it may be forcibly killed by the system. While the application is running in the foreground, the value in this property remains suitably large. If the application starts one or more long-running tasks using the beginBackgroundTaskWithExpirationHandler: method and then transitions to the background, the value of this property is adjusted to reflect the amount of time the application has left to run.
- (Object) delegate
The delegate of the application object. The delegate must adopt the UIApplicationDelegate formal protocol. UIApplication assigns and does not retain the delegate.
- (Boolean) idleTimerDisabled
A Boolean value that controls whether the idle timer is disabled for the application. The default value of this property is NO. When most applications have no touches as user input for a short period, the system puts the device into a “sleep” state where the screen dims. This is done for the purposes of conserving power. However, applications that don’t have user input except for the accelerometer—games, for instance—can, by setting this property to YES, disable the “idle timer” to avert system sleep. Important: You should set this property only if necessary and should be sure to reset it to NO when the need no longer exists. Most applications should let the system turn off the screen when the idle timer elapses. This includes audio applications. With appropriate use of Audio Session Services, playback and recording proceed uninterrupted when the screen turns off. The only applications that should disable the idle timer are mapping applications, games, or similar programs with sporadic user interaction.
- (UIWindow) keyWindow (readonly)
The application's key window. (read-only) This property holds the UIWindow object in the windows array that is most recently sent the makeKeyAndVisible message.
- (Boolean) networkActivityIndicatorVisible
A Boolean value that turns an indicator of network activity on or off. Specify YES if the application should show network activity and NO if it should not. The default value is NO. A spinning indicator in the status bar shows network activity. The application may explicitly hide or show this indicator.
- (Boolean) protectedDataAvailable (readonly)
A Boolean value indicating whether content protection is active. (read-only) The value of this property is NO if content protection is enabled and the device is currently locked. The value of this property is set to YES if the device is unlocked or if content protection is not enabled.When the value of this property is NO, files that were assigned the NSFileProtectionComplete protection key cannot be read or written by your application. The user must unlock the device before your application can access them.
- (Array) scheduledLocalNotifications
All currently scheduled local notifications. This property holds an array of UILocalNotification instances representing the current scheduled local notifications. You can set or reset the local notifications in the array as well as access them.This method may be faster than using scheduleLocalNotification: when scheduling a large number of notifications.Note: Prior to iOS 4.2, this property was a read-only method. A setter method has been added and the method has been converted to a read-write property. When you set this property, UILocalNotification replaces all existing notifications by calling cancelLocalNotification: and then calling scheduleLocalNotification: for each new notification.
- (CGRect) statusBarFrame (readonly)
The frame rectangle defining the area of the status bar. (read-only) The value of this property is CGRectZero if the status bar is hidden.
- (Boolean) statusBarHidden
A Boolean value that determines whether the status bar is hidden.
- (UIInterfaceOrientation) statusBarOrientation
The current orientation of the application's status bar. The value of this property is a constant that indicates an orientation of the receiver's status bar. See UIInterfaceOrientation for details. Setting this property rotates the status bar to the specified orientation without animating the transition. If your application has rotatable window content, however, you should not arbitrarily set status-bar orientation using this method. The status-bar orientation set by this method does not change if the device changes orientation. For more on rotatable window views, see View Controller Programming Guide for iOS.
- (NSTimeInterval) statusBarOrientationAnimationDuration (readonly)
The animation duration in seconds for the status bar during a 90 degree orientation change. (read-only) You should double the value of this property for a 180 degree orientation change in the status bar.
- (UIStatusBarStyle) statusBarStyle
The current style of the status bar. The value of the property is a UIStatusBarStyle constant that indicates the style of status. The default style is UIStatusBarStyleDefault. The animation slides the status bar out for the old orientation and slides it in for the new orientation.
- (UIUserInterfaceLayoutDirection) userInterfaceLayoutDirection (readonly)
Returns the layout direction of the user interface. (read-only) This method specifies the general user interface layout flow direction. See “UIUserInterfaceLayoutDirection” for a description of the constants returned by this property.
- (Array) windows (readonly)
The application's visible and hidden windows. (read-only) This property returns an array of the application's visible and hidden windows. The windows are ordered back to front.
Class Method Details
+ (UIApplication) sharedApplication
Returns the singleton application instance.
Instance Method Details
- (UIBackgroundTaskIdentifier) beginBackgroundTaskWithExpirationHandler(handler)
Marks the beginning of a new long-running background task. This method lets your application continue to run for a period of time after it transitions to the background. You should call this method at times where leaving a task unfinished might be detrimental to your application’s user experience. For example, your application could call this method to ensure that had enough time to transfer an important file to a remote server or at least attempt to make the transfer and note any errors. You should not use this method simply to keep your application running after it moves to the background. Each call to this method must be balanced by a matching call to the endBackgroundTask: method. Applications running background tasks have a finite amount of time in which to run them. (You can find out how much time is available using the backgroundTimeRemaining property.) If you do not call endBackgroundTask: for each task before time expires, the system kills the application. If you provide a block object in the handler parameter, the system calls your handler before time expires to give you a chance to end the task.You can call this method at any point in your application’s execution. You may also call this method multiple times to mark the beginning of several background tasks that run in parallel. However, each task must be ended separately. You identify a given task using the value returned by this method.This method can be safely called on a non-main thread.
- (Object) beginIgnoringInteractionEvents
Tells the receiver to suspend the handling of touch-related events. You typically call this method before starting an animation or transition. Calls are nested with the endIgnoringInteractionEvents method.
- (Object) beginReceivingRemoteControlEvents
Tells the application to begin receiving remote-control events. Remote-control events originate as commands issued by headsets and external accessories that are intended to control multimedia presented by an application. To stop the reception of remote-control events, you must call endReceivingRemoteControlEvents.
- (Object) cancelAllLocalNotifications
Cancels the delivery of all scheduled local notifications.
- (Object) cancelLocalNotification(notification)
Cancels the delivery of the specified scheduled local notification. Calling this method also programmatically dismisses the notification if it is currently displaying an alert.
- (Boolean) canOpenURL(url)
Returns whether an application can open a given URL resource. This method guarantees that that if openURL: is called, another application will be launched to handle it. It does not guarantee that the full URL is valid.
- (Object) clearKeepAliveTimeout
Removes a previously installed periodic handler block. If your VoIP application no longer needs to be woken up at periodic intervals, you can use this method to remove any previously installed handler.
- (Object) completeStateRestoration
Tells the app that your code has finished any asynchronous state restoration. UIKit restores your application’s state synchronously on the main thread. If you choose to perform additional state restoration on a secondary thread, call the extendStateRestoration method to inform UIKit of that fact. Call this method after you finish with your background work to let the system know that state restoration is complete.
- (UIRemoteNotificationType) enabledRemoteNotificationTypes
Returns the types of notifications the application accepts. The values in the returned bit mask indicate the types of notifications currently enabled for the application. These types are first set when the application calls the registerForRemoteNotificationTypes: method to register itself with Apple Push Notification Service. Thereafter, the user may modify these accepted notification types in the Notifications preference of the Settings application. This method returns those initial or modified values. iOS does not display or play notification types specified in the notification payload that are not one of the enabled types. For example, the application might accept icon-badging as a form of notification, but might reject sounds and alert messages, even if they are specified in the notification payload.
- (Object) endBackgroundTask(identifier)
Marks the end of a specific long-running background task. You must call this method to end a task that was started using the beginBackgroundTaskWithExpirationHandler: method. If you do not, the system may kill your application. This method can be safely called on a non-main thread.
- (Object) endIgnoringInteractionEvents
Tells the receiver to resume the handling of touch-related events. You typically call this method when, after calling the beginIgnoringInteractionEvents method, the animation or transition concludes. Nested calls of this method should match nested calls of the beginIgnoringInteractionEvents method.
- (Object) endReceivingRemoteControlEvents
Tells the application to stop receiving remote-control events. Remote-control events originate as commands issued by headsets and external accessories that are intended to control multimedia presented by an application.
- (Object) extendStateRestoration
Tells the app that your code is restoring state asynchronously. UIKit restores your application’s state synchronously on the main thread. If you choose to perform additional state restoration on a secondary thread, call this method to inform UIKit of that fact. You must balance each call to this method with a matching call to the completeStateRestoration method.Calling this method is a safety precaution in the event that your app crashes at launch time due to problems restoring its state. If you call this method but do not call the matching completeStateRestoration method before a crash occurs, the system throws away any saved state information. Doing so prevents your app from crashing during subsequent launches because of issues caused by trying to restore your app’s state.
- (Boolean) isIgnoringInteractionEvents
Returns whether the receiver is ignoring events initiated by touches on the screen.
- (Boolean) openURL(url)
Opens the resource at the specified URL. The URL can locate a resource in the same or other application. If the resource is another application, invoking this method may cause the calling application to quit so the other one can be launched.You may call canOpenURL: before calling this one to verify that there is an application that can handle it.
- (Object) presentLocalNotificationNow(notification)
Presents a local notification immediately.
- (Object) registerForRemoteNotificationTypes(types)
Register to receive notifications of the specified types from a provider via Apple Push Service. When you send this message, the device initiates the registration process with Apple Push Service. If it succeeds, the application delegate receives a device token in the application:didRegisterForRemoteNotificationsWithDeviceToken: method; if registration doesn’t succeed, the delegate is informed via the application:didFailToRegisterForRemoteNotificationsWithError: method. If the application delegate receives a device token, it should connect with its provider and pass it the token. iOS does not display or play notification types specified in the notification payload that are not one of the requested ones. For example, if alert messages are not one of the accepted notification types, iOS does not display an alert even if one is specified in the notification payload. To find out what the application’s current notification types are, call the enabledRemoteNotificationTypes method.
- (Object) scheduleLocalNotification(notification)
Schedules a local notification for delivery at its encapsulated date and time.
- (Boolean) sendAction(action, to:target, from:sender, forEvent:event)
Sends an action message identified by selector to a specified target. Normally, this method is invoked by a UIControl object that the user has touched. The default implementation dispatches the action method to the given target object or, if no target is specified, to the first responder. Subclasses may override this method to perform special dispatching of action messages.By default, this method pushes two parameters when calling the target. These last two parameters are optional for the receiver because it is up to the caller (usually a UIControl object) to remove any parameters it added. This design enables the action selector to be one of the following:- (void)action- (void)action:(id)sender- (void)action:(id)sender forEvent:(UIEvent *)event
- (Object) sendEvent(event)
Dispatches an event to the appropriate responder objects in the application. Subclasses may override this method to intercept incoming events for inspection and special dispatching. iOS calls this method for public events only.
- (Boolean) setKeepAliveTimeout(timeout, handler:keepAliveHandler)
Configures a periodic handler for VoIP applications. A voice-over-IP (VoIP) application can use this method to install a handler whose job is to maintain the application’s network connection with a VoIP server. This handler is guaranteed to be called before the specified timeout value but may be called at a slightly different time interval in order to better align execution of your handler with other system tasks, and thereby save power. Your handler has a maximum of 10 seconds to perform any needed tasks and exit. If it does not exit before time expires, the application is suspended. Timeout values and handlers are not persisted between application launches. Therefore, if your application is terminated for any reason, you must reinstall the handler during the next launch cycle. For calls to this method to succeed, the application must have the voip value in the array associated with the UIBackgroundModes key in its Info.plist file. Calling this method replaces the previously installed handler and timeout values, if any.
- (Object) setNewsstandIconImage(image)
Sets the icon of a Newsstand application to an image depicting the current issue of a publication. The Newsstand application icon is typically downloaded from the application’s server for each issue.
- (Object) setStatusBarHidden(hidden, withAnimation:animation)
Hides or shows the status bar, optionally animating the transition. See the descriptions of the constants of the UIStatusBarAnimation type for more information.
- (Object) setStatusBarOrientation(interfaceOrientation, animated:animated)
Sets the application's status bar to the specified orientation, optionally animating the transition. Calling this method changes the value of the statusBarOrientation property and rotates the status bar, animating the transition if animated is YES . If your application has rotatable window content, however, you should not arbitrarily set status-bar orientation using this method. The status-bar orientation set by this method does not change if the device changes orientation.
- (Object) setStatusBarStyle(statusBarStyle, animated:animated)
Sets the style of the status bar, optionally animating the transition to the new style. The animation slides the status bar out toward the top of the interface.
- (Integer) supportedInterfaceOrientationsForWindow(window)
Returns the default set of interface orientations to use for the view controllers in the specified window. This method returns the default interface orientations for the app. These orientations are used only for view controllers that do not specify their own. If your app delegate implements the application:supportedInterfaceOrientationsForWindow: method, the system does not call this method.The default implementation of this method returns the app’s default set of supported interface orientations, as defined in the UIInterfaceOrientation key of the Info.plist file. If the file does not contain that key, this method returns all interface orientations for the iPad idiom and returns all interface orientations except the portrait upside-down orientation for the iPhone idiom.
- (Object) unregisterForRemoteNotifications
Unregister for notifications received from Apple Push Service. You should call this method in rare circumstances only, such as when a new version of the application drops support for remote notifications. Users can temporarily prevent applications from receiving remote notifications through the Notifications section of the Settings application. Applications unregistered through this method can always re-register.