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
2 answers

How to show Alert when UIApplication is not able to open URL?

This method opens up the url in Safari when the website string is not null and it is atleast of length 3. But when I have supplierWebsite=@"www.heritage.com", nothing happens. I know that heritage.com is not valid website and so it is not activating…
Shaunak
  • 707
  • 1
  • 9
  • 29
2
votes
2 answers

How to calculate time application spent in background in iOS

How to find the time app spent in suspended state (when app minimized on the device). I want to inform the user that your app spent 30 mins in background and please re-login to the app.
Srivathsa
  • 606
  • 10
  • 34
2
votes
2 answers

canOpenURL always return FALSE

I´m trying to open an URL with UIApplication, but when I run: [[UIApplication sharedApplication] canOpenURL:urlToUpdate The url is created with a String and NSString *urlStringToOpenEscaped = [urlStringToOpen…
xarly
  • 2,054
  • 4
  • 24
  • 40
2
votes
1 answer

remove BadgeNumber from other app (jailbreak iphone)

I have 2 apps that I want to connect together, I want to control the "BagdeNumer" will running the other app sometime to show 1 or sometime show 100 ... I using this command to control on the Badge in the app im in NOW .. [[UIApplication…
LiorKatz
  • 53
  • 7
2
votes
1 answer

Refresh ios UIViewController on applicationDidBecomeActive

I need to re-create my current UIViewController in my iOS application on applicationDidBecomeActive. In my code, I adding a lot of runtime graphics to screen, so I think best way to completely recreate it. I need to solve 2 tasks: Determine, which…
Andrey
  • 2,659
  • 4
  • 29
  • 54
2
votes
1 answer

IBAction not functioning after I renamed xib file

I have an universal application that had all views in the same file MainWindow.xib. Today I decided to separate these views into their respective xib files (to have MainMenuController.h, MainMenuController.m and MainMenuController.xib for example).…
Murat Ögat
  • 1,342
  • 2
  • 14
  • 24
2
votes
1 answer

keyWindow = nil only on iPad

I got a problem with my applications keyWindow on iPad. I designen my app for iPhone and added the iPad support later by setting the device family and adding a new storyboard for iPad. Everything is fine so far, I can open the app on the ipad and…
E. Lüders
  • 1,495
  • 1
  • 12
  • 27
2
votes
1 answer

Prevent iPhone to sleep

I using accelerometer in my app and i'm using [UIApplication sharedApplication].idleTimerDisabled = YES; to prevent the device to sleep. It works fine, but this way the screen is always on full bright, there is a way to prevent the device to sleep…
douglasd3
  • 761
  • 2
  • 10
  • 27
2
votes
2 answers

Differentiate between application launch and application awake

I need to be able to differentiate between application didFinishLaunching and application entering background and being loaded back into the foreground. I noticed that if I register for the UIApplicationDidBecomeActiveNotification, it is called in…
yroc
  • 151
  • 7
2
votes
1 answer

iphone idle timer check for after a particular event

Here am developing a application which i should start this idle timer event after the user is get signed in and i should stop this event after the user is signout the application. Here i have implemented a logic like subclassing the UIApplication…
nik
  • 2,289
  • 6
  • 37
  • 60
2
votes
1 answer

iOS custom status bar that only replaces carrier icon

I'm creating a zombie preparedness app for iOS and I thought it would be cool to have an "Apocalypse mode" which is similar to Airplane mode in that it replaces the status bar carrier icon with a little airplane except possibly with a little…
Ben Holland
  • 2,309
  • 4
  • 34
  • 50
2
votes
1 answer

Launching app2 from app1 & passing data

I have 2 different applications on the same device. I want to open first application from second one. How would that happen? Basically, I want to pass some data from app1 to app2 by tapping on some button inside app1. Once tapped, app2 should be…
Abhinav
  • 37,684
  • 43
  • 191
  • 309
1
vote
2 answers

How to remove any screen when application install on device?

I have a requirement that when application install on device then it will never show any screen and start a thread in background for 30 seconds. When complete that time then it will show a screen in application. I mean to say that when we install an…
ios
  • 552
  • 5
  • 22
1
vote
1 answer

MainWindow IBOutlet properties for window, tabBarController log as (null) even though outlets are connected

In my AppDelegate.h I have @property (nonatomic, strong) IBOutlet UIWindow *window and @property (nonatomic, strong) IBOutlet UITabBarController *tabBarController. In the implementation I @synthesize *window = _window, *tabBarController =…
1
vote
0 answers

Define a Class instance and create its objects and cast with it

I have an interesting question What I am trying to do is to use object's class (AppDelegate in this case) And then use this class object like the next Code. But the compiler doesn't like it. Class appDelegateClass=[[UIApplication…