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
0
votes
1 answer

How to display an image on a UiApplication in BlackBerry?

How to display an image on a UiApplication? I have a code that displays a button and when clicked it goes to a MainScreen, but I'd like to display an image below that button. I found a way to insert a zoomable image but not a static one. Here's my…
Marcelo
  • 15
  • 4
0
votes
0 answers

UIApplication termination state

Is there a state variable somewhere that tells me the application is about to quit (after UIApplicationWillTerminateNotification was sent)? UIApplication's applicationState does not seem to account for this state.
Morrowless
  • 6,856
  • 11
  • 51
  • 81
0
votes
1 answer

ios shareApplication rootviewcontroller.frame flip-flops on Y axis

I have an iPad application where I'm moving the application's frame "up" every time the soft keyboard is shown. [UIApplication sharedApplication].keyWindow.rootViewController.view.frame = CGRectMake(0, 150, 1024, 768); The clincher is that on some…
Jacksonkr
  • 31,583
  • 39
  • 180
  • 284
-1
votes
1 answer

How do I get `UIScreen.main.scale` after iOS 16

UIScreen.main.scale will deprecated. here it the document in UIKit.UIScreen @available(iOS, introduced: 2.0, deprecated: 100000, message: "Use a UIScreen instance found through context instead: i.e, view.window.windowScene.screen") open…
violethill
  • 57
  • 5
-1
votes
1 answer

Removing the gloss from app icon when app installed on the device

When we pass the Application icon files inside CFBundleIconFiles, we get a rounded gloss on upper half of the icon. How can we get rid of it like in icon for "Settings" app.
Abhinav
  • 37,684
  • 43
  • 191
  • 309
-1
votes
2 answers

UIApplicationShortcutItem not showing base on Info.plist

I have 5 items defined in my plist. It only showed 4. ‍♂️ I've tried in Simulator and the actual iPhone XS Max. UIApplicationShortcutItemIconFile home
code-8
  • 54,650
  • 106
  • 352
  • 604
-1
votes
2 answers

Calling multiple URLs in succession using UIApplication.shared.open - only opens first

I'm trying to create a wifi tress test by opening multiple URLs in succession in Xcode/Swift for iPad. It seems to open only the first successfully. The "sleep(x)" call makes no difference. Code snippet: func counter() { seconds -= 1 …
wiwinut
  • 75
  • 1
  • 7
-1
votes
2 answers

UIApplication applicationState must be used from main thread only

I am trying to do some unit testing for the API. Here is the actual function. func registerApi(path: String, player_id: Int, contest_id: Int, country_id: Int, success: () -> Void) { ServiceHelper.sharedInstance.sendRequest(path:…
Rob
  • 2,086
  • 18
  • 25
-1
votes
2 answers

UIApplication network indicator color swift

I need to change UIApplication network indicator color. It is black by default. I want white network indicator color.
Sukhpreet
  • 933
  • 1
  • 9
  • 24
-1
votes
2 answers

UIApplication.shared.keyWindow?' s view global action method

I have added a button, which I want to see top of all my ViewControllers with UIApplication.shared.keyWindow?.addSubview(mybutton) What I am trying to figure out is how can I make a global function that this button can call, no matter of which is…
radioaktiv
  • 2,437
  • 4
  • 27
  • 36
-1
votes
1 answer

Capturing touches in UIApplication and calling a function in ViewController causing error

I have the below Swift 2 code set up that captures all touches across the whole app. It alerts when touches are occurring and when touches have stopped. I am wanting to access two functions in another view controller named myVC when touches are…
user4806509
  • 2,925
  • 5
  • 37
  • 72
-1
votes
1 answer

ios call function in background mode

my app running in the background and I want to take the html data from the web server every 60 second. (with alamofire or nsurlconnection etc..) but I could not find sample code associated with it. Is it possible to do something like this. updated…
user2512558
  • 21
  • 2
  • 7
-1
votes
1 answer

How to hide Characters when Call Objective-C

I have a URL for conference call from iPhone, tel:1600123456,,,,,,1234# This is the conference call number followed by the Passcode. While calling the whole number and characters are displayed. How can I hide the ',,' in the call.
Vineesh TP
  • 7,755
  • 12
  • 66
  • 130
-1
votes
1 answer

How to swizzle UIApplication in iOS?

I need to Swizzle UIApplication class methods especially "application:handleOpenURL:". I have added a category class of UIApplication. I have exchanged my own method with the original method but, it never triggered. The Swizzle class called very…
Yuvaraj.M
  • 9,741
  • 16
  • 71
  • 100
-1
votes
1 answer

Pass value from UIApp or Google Spreadsheet to gmail

I'm using Google Apps for Education. Since my Principal does not allow me enable Shared contact, and the paid version of Shared Contacts for Gmail is not satisfied my needs. I am thinking the way to integrate address book to users' gmail in…
1 2 3
32
33