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

unable to access UIApplication.SharedApplication.KeyWindow during the launch of the app as keywindow is always null

When my app is launched i show the Storyboad with an image in it like a splash screen. Then i call LoadApplication(new App()) from FinishedLaunching() method in AppDelegate class. In my App.cs, I need to access…
0
votes
0 answers

Get parameters from URL while not launching app for the first time in viewWillAppear

we provide some parameters using URL schema and it works well if we launch app for the first time. I have provided a custom initialization in AppDelegate: func application(_ app: UIApplication, open url: URL, options:…
Viktor Vostrikov
  • 1,322
  • 3
  • 19
  • 36
0
votes
0 answers

Problem with using UIApplication.shared.keyWindow?.rootViewController

In my app I use this code: func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let mainTabBarController = UIApplication.shared.keyWindow?.rootViewController as? MainTabBarController …
0
votes
2 answers

Where to put [[UIApplication sharedApplication] setStatusBarHidden:YES];?

I need some help. I want that my app runs without status bar. [[UIApplication sharedApplication] setStatusBarHidden:YES]; I put this line into appDelegate in - (BOOL)application:(UIApplication…
Tunyk Pavel
  • 2,473
  • 6
  • 31
  • 46
0
votes
0 answers

Acess the AlertController that comes during phone call

I have implemented a call functionality on button click. After that a popup appears with number as title and with options - cancel and Call. I want to show another controller with a message - call not placed if that cancel is clicked. Please help me…
TheTravloper
  • 236
  • 5
  • 16
0
votes
0 answers

iOS App backgrounded even when isIdleTimerDisabled = false

I'm building an alarm clock app and I want it to stay open during the night. I have a view that shows the time and instructs the user to keep the app open, and when the user starts the alarm, I set: UIApplication.shared.isIdleTimerDisabled =…
Yariv Adam
  • 844
  • 9
  • 24
0
votes
1 answer

UIApplication's `beginIgnoringInteractionEvents` not working

First of all my apology for long question, i personally prefer short precise question. Background i am developing a search feature within a UITableView. To Store data i'm using core data. To show the results i'm using NSFetchedResultsController. In…
Ratul Sharker
  • 7,484
  • 4
  • 35
  • 44
0
votes
2 answers

Not fully understanding UIApplication.shared.canOpenUrl

Any ideea how is this getting true in appUrl = "http://dum:site2015@jobz.store.com/ if UIApplication.shared.canOpenURL(appUrl!){ if #available(iOS 10.0, *) { UIApplication.shared.open(appUrl!) } and in url scheme i have…
Mohamed Lee
  • 267
  • 1
  • 3
  • 18
0
votes
2 answers

Refresh Control not animating- UItableView

I have a UITableView that has a refreshControl added as func addRefreshControl() { refreshControl.addTarget(self, action: #selector(refresh), for: .valueChanged) testTableView.addSubview(refreshControl) } When i scroll the tableView down…
Costello
  • 105
  • 6
0
votes
0 answers

How can I open my second App in a specific VC if the application is already running?

So I have 2 targets , I managed to open the SecondTarget from the FristTarget with: if UIApplication.shared.canOpenURL(aUrl!){ if #available(iOS 10.0, *) { UIApplication.shared.open(aUrl!) } else { //…
Mohamed Lee
  • 267
  • 1
  • 3
  • 18
0
votes
1 answer

How to execute a task even when the application is in background or lock mode till it finishes

Below code i have used to write certain task in background mode.But this executes only for 3mins after it ends task. So i would like to execute particular task till it finishes. func registerBackgroundTask() { backgroundTask =…
Malathi
  • 47
  • 5
0
votes
1 answer

How to differentiate lock screen and home button (background multitasking) on applicationWillResignActive in the app delegate

I am writing an alarm clock app. Please correct me if I am wrong: On both events (lock & home button in iOS 4.x) the applicationWillResignActive: method is called. When locked my app can keep on running (forever if DeepSleepPreventer.h is used) to…
Obiwahn
  • 2,677
  • 2
  • 26
  • 36
0
votes
2 answers

UIWindow iPhoneX custom bounds

I have an old project that doesn't uses autolayout and lot of legacy code. I want to make it compatible with iPhone X till I complete a code rewrite of the entire project. I thought of using NotchKit but it doesn't gives expected results. Is there a…
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
0
votes
1 answer

Take the user to Passcode Settings page from your app?

Using UIApplicationOpenSettingsURLString will take the user to app settings, is there any url for taking the user to Passcode or FaceID settings page of Setting app ?
guhan0
  • 666
  • 6
  • 19
0
votes
1 answer

canOpenURL always return false even if I specify Launch Service Keys

I am trying to detect if a specific app is installed and according to the docs, the canOpenURL method could help. Also I am on iOS 11, and according to the docs, for > iOS 9, this is important thing to keep in mind: Important If your app is linked…
Whirlwind
  • 14,286
  • 11
  • 68
  • 157