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

When should I release [[UIApplication sharedApplication] delegate] object?

I'm using the following code many times in my app (especially to manage a NavigationController): MyAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; When should I release it ? Thx for helping, Stephane
Stephane
  • 4,978
  • 9
  • 51
  • 86
0
votes
1 answer

iOS: Can't set UIApplication idleTimerDisabled to YES in didFinishLaunchingWithOptions

I have an iPad app where the user can set the idleTimerDisabled to YES or NO via a switch in preferences. That part works fine. However, initially setting it to YES in the app delegate's didFinishLaunchingWithOptions method if it's the first time…
Gregir
  • 1,574
  • 5
  • 21
  • 43
0
votes
1 answer

Cannot access appdelegate instance variable from related View Controller

My app name is PropertiesSearch so the project contains the following files: PropertiesSearchAppDelegate.h PropertiesSearchAppDelegate.m PropertiesSearchViewController.h PropertiesSearchViewController.m I declared an instance variable (ListingNav)…
Stephane
  • 4,978
  • 9
  • 51
  • 86
0
votes
1 answer

UIApplication.keywindow ,must be used from main thread only warning

DispatchQueue.main.async { } This cause error in my Extension How I use it let topController = UIApplication.shared.topMostViewController()
9to5ios
  • 5,319
  • 2
  • 37
  • 65
0
votes
1 answer

no visible @interface for 'UIApplication' declares the selector 'launchApplicationWithIdentifier'

I just starting to learn how to write iOS tweaks. Tried to write a tweak in theos, but this part of code: #import %hook SBStatusBarManager - (void) handleStatusBarTapWithEvent: (id)arg1{ [[UIApplication sharedApplication]…
checkm8
  • 13
  • 1
0
votes
1 answer

Is it possible to disable Notification settings for the application in Xamarin Forms

Is there a way to disable the alert settings from an application through code? I am already enabling these settings using below code, but I cant find any method to disable these settings again on user action. var pushSettings =…
0
votes
2 answers

Warning message on statusBarStyle on set lightContent

How to resolve this issue warning issue UIApplication.shared.statusBarStyle = .lightContent Warning Messages 'statusBarStyle' was deprecated in iOS 13.0: Use the statusBarManager property of the window scene instead.
kiran
  • 4,285
  • 7
  • 53
  • 98
0
votes
2 answers

How to make web URL not to animate when been opened from Application?

I'm using following code to open URL on a button click from application: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.innotrack.eu///"]]; But when it opens the URL on safari, it animates, Requirement is to…
rptwsthi
  • 10,094
  • 10
  • 68
  • 109
0
votes
2 answers

Use image file from "Assets.xcassets" for changing iOS app icon programmatically

I'm trying to develop Icon Changing feature and I was going to use images from Assets.xcassets as app icon image. I tried changing app icon using setAlternateIconName(_:completionHandler:) after adding CFBundleAlternateIcons data to info.plist But…
Dan Choi
  • 83
  • 2
  • 8
0
votes
0 answers

Phone app prompt works half the time swift

Im making an app which imports all contacts stored on a device to the app UITableView And when cell is selected the dialler should pop up with a selected phone number. However it works half the time import UIKit import Contacts import…
Russ
  • 53
  • 1
  • 9
0
votes
3 answers

How to get a view to update automatically after period of inactivity?

I am trying to add a timeout feature to my SwiftUI app. The view should be updated when timeout is reached. I have found code on a different thread, which works for the timeout part, but I cannot get the view to update. I am using a static property…
spadolini
  • 1
  • 2
0
votes
1 answer

URL can't be opened from the application

In an application, this: http://web.extebtion/projects/projectName/myaccount.php?1310625280.37+TE1PUFha-MDEyMzQ1Njc4OV85X3NpbXVsYXRvcg==+1310625280.37 (TYPE OF) URL is being tried to open by: [[UIApplication sharedApplication] openURL:[NSURL…
rptwsthi
  • 10,094
  • 10
  • 68
  • 109
0
votes
1 answer

UIApplication.shared.open only works with https

I trying to open url with UIApplication.shared.open function but i'm little bit confused because its not working for www.google.com and its working for https://www.google.com. struct GetIsoCode: View { @State var titile = "www.google.com" …
Sham Dhiman
  • 1,348
  • 1
  • 21
  • 59
0
votes
1 answer

How to Config Social Networks Login inside AppDelegate OpenURLOptionsKey

How to configure social login inside openurl. func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool { return GIDSignIn.sharedInstance().handle(url) } //…
kiran
  • 4,285
  • 7
  • 53
  • 98
0
votes
1 answer

View won't show when calling by function in SwiftUI

I have this problem. I'm trying to show Ads in my app using AdMob. It all works fine (i did some debug) but the view containing the video is not showing... I can't figure out why it's not showing on the top of my content. Here is the the class that…
Cristian
  • 3
  • 1