Questions tagged [uiapplication]

The UIApplication class provides a centralized point of control and coordination for apps running on iOS. Every app must have exactly one instance of UIApplication (or a subclass of UIApplication). When an app is launched, the UIApplicationMain function is called; among its other tasks, this function creates a singleton UIApplication object. Thereafter you access this object by invoking the sharedApplication class method.

The UIApplication class provides a centralized point of control and coordination for apps running on iOS. Every app must have exactly one instance of UIApplication (or a subclass of UIApplication). When an app is launched, the UIApplicationMain function is called; among its other tasks, this function creates a singleton UIApplication object. Thereafter you access this object by invoking the sharedApplication class method.

A major role of a UIApplication object is to handle the initial routing of incoming user events. It also dispatches action messages forwarded to it by control objects (UIControl) to the appropriate target objects. In addition, the UIApplication object maintains a list of all the windows (UIWindow objects) currently open in the app, so through those it can retrieve any of the app’s UIView objects. The app object is typically assigned a delegate, an object that the app informs of significant runtime events—for example, app launch, low-memory warnings, and app termination—giving it an opportunity to respond appropriately.

Apps can cooperatively handle a resource such as an email or an image file through the openURL: method. For example, an app opening an email URL with this method may cause the mail client to launch and display the message.

The programmatic interfaces of UIApplication allow you to manage behavior that is specific to the device. Use this object to do the following:

  • Control the app’s response to changes in interface orientation.

  • Temporarily suspend incoming touch events.

  • Turn proximity sensing (of the user’s face) off and on again.

  • Register for remote notifications.

  • Trigger the undo-redo UI (applicationSupportsShakeToEdit).

  • Determine whether an installed app can open a URL (canOpenURL:).

  • Extend the execution of the app so that it can finish a task in the background.

  • Schedule and cancel local notifications.

  • Coordinate the reception of remote-control events.

  • Perform app-level state restoration tasks.

UIApplication defines a delegate that must adopt the UIApplicationDelegate protocol and implement some of the protocol methods.

Subclassing Notes

Most apps should never need to subclass the UIApplication class. Most apps use an app delegate to manage interactions between the system and the app.

The only situation where you might need to subclass UIApplication is when you are implementing a custom event or action dispatching mechanism. In that situation, you might override the sendEvent: or sendAction:to:from:forEvent: methods to implement that mechanism. However, the cases where this is required are very rare and should be avoided whenever possible.

484 questions
2
votes
4 answers

When to update icon badge number in iOS?

I have a to do list app and I want to show the number of uncompleted tasks in the icon badge. My question is: Should I update the badge number every time the user deletes/adds a new task in the app or only update it when the app is about to enter…
Balázs Vincze
  • 3,550
  • 5
  • 29
  • 60
2
votes
1 answer

applicationIconBadgeNumber - How to display with empty value?

How to I make a red number indicators without any number inside it ? Or anyone have any ideas that help user know if the App is running on background or not ? Thanks for helping me Tung Do
Tung Do
  • 1,423
  • 3
  • 13
  • 27
2
votes
0 answers

Is the method beginIgnoringInteractionEvents supposed to disable non-touch events?

I have a text box that is used to look up from a large list of potential options via a web service and then list them in a table view. On start/complete I call them + (void)showProgressHUDIfNecessary { if ([RestKitWebServiceRequest…
tacos_tacos_tacos
  • 10,277
  • 11
  • 73
  • 126
2
votes
2 answers

UIView not handling touches

I have set my status bar hidden in my Application. [application setStatusBarHidden:YES]; I have added an UIView on the window as a subview at 0,0,320,40. But I am not able to get touches on my View ? But if i am changing the 'Y' position like…
Biranchi
  • 16,120
  • 23
  • 124
  • 161
2
votes
0 answers

How can I pass a UIEvent to a UIScrollView

I am subclassing UIWindow and creating an implementation of sendEvent: as follows: - (void)sendEvent:(UIEvent *)event { [super sendEvent:event]; // Send event to UIScrollView here } How can I send the event to a UIScrollView. I tried…
rickharrison
  • 4,867
  • 4
  • 35
  • 40
2
votes
1 answer

Encapsulation of AppDelegate variables in Swift

Recently Swift introduced the access modifiers. What about setting some stuff in my AppDelegate private? I wanted some of the ivars be private, like window, for example. But I can't do so, because compiler shows a warning that I'm "Declaring a…
A gee
  • 21
  • 1
2
votes
1 answer

backgroundTimeRemaining less than 10 seconds on iOS 7

I am periodically getting a ~9 second background time remaining. I believe it should be close to 180 seconds. However that's not what I am seeing. - (void)applicationDidEnterBackground:(UIApplication *)application { UIApplication *app =…
madmik3
  • 6,975
  • 3
  • 38
  • 60
2
votes
1 answer

UIApplicationStateInactive on iOS 8

I have a camera app that is running fine on iOS 7. In the viewDidAppear call of my MainViewControllerI am first checking if the application state in not inactive and the application is not in background. The code sample is given below. -(void)…
shshnk
  • 1,621
  • 14
  • 26
2
votes
1 answer

UIApplication sharedApplication in XCTest for log out

For my setUp and tearDown methods in an XCTest suite, I need to call [[UIApplication sharedApplication] delegate] and then have it perform a signout method. The signout appears to call the correct methods, but many properties on the…
2
votes
3 answers

Force iPhone to open Facebook's URL in Web Navigator (Safari, Chrome, Opera Mobile, etc)

i have a simple question: I can´t force the [UIApplication sharedApplication] openUrl: to open the url in the web navigator, always open the Facebook app and don´t go to the facebook pages.
Erusso87
  • 667
  • 1
  • 7
  • 19
2
votes
3 answers

iOS Background Fetch mode can be used to schedule some operation in the future that doesn't actually fetch remote data?

I'm doing an app that requires to reschedule local notification on daily basis. I'm aware about the repeatInterval property, but repetitioon here is like each 2 days etc. I've seen silent notifications, but they can be used only with push…
Andrea
  • 26,120
  • 10
  • 85
  • 131
2
votes
1 answer

iOS- Ways to launch application

I have an on-air application and I block some old version (must to update). I noticed that an old version (version I blocked) don't have "must upgrade" appear. To solve that issue, in thought all the ways to launch my application: Tap the app…
gran33
  • 12,421
  • 9
  • 48
  • 76
2
votes
0 answers

Can I make a phone call in my app without an alertview popping up and return to app?

I have been using: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://123456789"]]; to make a phone call from my app and after the phone call it will return to my app. The only problem is that I don't want to have the…
SirRupertIII
  • 12,324
  • 20
  • 72
  • 121
2
votes
2 answers

What is annotation:(id)annotation in openURL method?

In the app delegate, there is this method - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { I am wondering what the "annotation" is? Also, how would I…
evenodd
  • 2,026
  • 4
  • 26
  • 38
2
votes
5 answers

UIApplicationDidBecomeActiveNotification and setRightBarButtonItem:animated:

TL;DR Update: Basically what I need is to delay my code until iOS finishes its "app startup" animation. I would like to animate content of a navigation bar when my app becomes active. In my controller, I'm subscribed to…
Rudolf Adamkovič
  • 31,030
  • 13
  • 103
  • 118