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
1
vote
1 answer

iOS Launch Maps-App in-App on iPhone.

I launch the maps-App in my iPhone's App with the google-URL with the following code: NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@ %@&layer=t", latitute.text,longitute.text]; NSString* encodedString…
lightwave
  • 11
  • 2
0
votes
2 answers

iOS - How to finish a task before the App enter background

I'm developing an App and I'm facing a problem when users quit the app. Let's say the app is downloading 3 images. The user quits the app. How can I continue the download (because we're talking about 2 mo left and not 500 !)? I know something like…
Dabrut
  • 862
  • 1
  • 10
  • 25
0
votes
2 answers

Blackberry BarcodeScanner - barcodeDecode switch to MainScreen

Can somebody tell me how to close the Screen (which opened by the BarcodeScanner) and show the mainscreen again after the barcodeDecoded method was invoked? I can't get it right. I tried a lot, one of them was this: public void…
Digital Human
  • 1,599
  • 1
  • 16
  • 26
0
votes
2 answers

How to set up an iOS app by programmatically creating window and views?

I'd like to do away with XIB (Nib) files in my project, because that's just how I roll. However I'm finding that my AppDelegate class's method didFinishLaunchingWithOptions is never even called. I tried setting the principal class in my app's main…
user945620
0
votes
1 answer

MonoTouch Notify once a web link has been loaded by UIApplication.SharedApplication.OpenUrl

I've had a look around to try and work out how I can receive a notification for when a URL has been loaded by the shared application, and it appears I need to create a delegate which inherits from UIApplicationDelegate and override some of the…
0
votes
2 answers

Get Safari's last redirected URL to my main UIviewcontroller

In my app, I call Safari to open (UIApplication delegate), Safari comes into foreground and there are some url redirections. At last, there's a url that I want to save in my main application. How can I get this url and how can I return to my main…
Kostas Papa
  • 5
  • 1
  • 4
0
votes
1 answer

UIApplication removeStatusBarImageNamed doesn't work

i'm working on a jailbroken iphone with iOS 5.0.1, just want to access status bar image, and my code is as follows: -(void)addStatusBarImage { NSLog(@"addStatusBarImage"); [[UIApplication sharedApplication] addStatusBarImageNamed:@"sgtest"…
shaj04
  • 23
  • 4
0
votes
1 answer

With iOS 5 SDK how can I use the Custom UIApplication in my iOS App?

I wanted to customize UIApplication. So I have a subclassed UIApplication. My Application do not have a MainWindow.nib file. So how can I assign my Custom UIApplication to play the role of UIApplication?
RK-
  • 12,099
  • 23
  • 89
  • 155
0
votes
3 answers

working of main.m in iphone programing

Possible Duplicate: Is there any reason to modify the main.m file in your iOS applications? I am new in the iphone applications development and I want to know why we don't actively use the main.m file in the iphone programming. I saw in the many…
0
votes
0 answers

will my application be rejected if i use UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication

can i use below one ? let app = UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication for app store build instead of let app = UIApplication.shared in my application i was using let app = UIApplication.value(forKeyPath:…
0
votes
0 answers

Is there any way to open a specific Settings page from my own iOS app?

I want to open a specific device Settings page (e.g. Bluetooth) from my own iOS app. As far as I know (How do I open phone settings when a button is clicked?), previously (in iOS 11 and below versions) it was possible to open a specific Settings…
Darya
  • 11
  • 2
0
votes
4 answers

Can i have a single NSMutableArray in my multiple views application?

I have a navigational based application which has multiple views. Is it possible to use one single NSMutableArray for the whole applicaiton? Can i add objects to that NSMutableArray in one view and then remove object from the same NSMutableArray…
0
votes
1 answer

iOS Application is lauching again once it is closed

In IOS 4 if the application is closed by user manually then it is not launching again it crashes when launched and i cant do anything. I am testing it on Ipod4 When i pressed the hard key of ipad twice and close the app manually then i am not able…
Nilesh Tupe
  • 7,655
  • 5
  • 25
  • 30
0
votes
1 answer

applicationDidBecomeActive get called when iPhone's Lock Screen button is pressed

In my app , I check [UIPasteboard generalPasteboard].changeCount in - (void)applicationDidBecomeActive:(UIApplication *)application But I found that every time I press iPhone's Lock Screen button , this applicationDidBecomeActive will be called ,…
ximmyxiao
  • 2,622
  • 3
  • 20
  • 35
0
votes
1 answer

Releasing appDelegate instances?

Possible Duplicate: When should I release [[UIApplication sharedApplication] delegate] object? I'm creating instances of UIApplication many times in my app to access shared infos, like this: MyAppDelegate *appDelegate = (MyAppDelegate…
Stephane
  • 4,978
  • 9
  • 51
  • 86