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 get the details of apps installed in a device in my app

is there any way i can have an access to the name of applications that are installed in the current device in my app. is there any api's to get hold of this. thanks
Gani
  • 709
  • 3
  • 13
  • 21
0
votes
1 answer

Change status bar back to default after changing it to `Light`, per view Controller scenario

I want to be able to change the status bar color on a per view controller basis. My ViewController flow is A->B->C. The launch status bar color is black (in A), and I change it to white in view Controller B. I use the following in Bs viewDidLoad: …
DevC
  • 6,982
  • 9
  • 45
  • 80
0
votes
3 answers

Can we hide the status bar?

Not just the bar but the texts the battery sign etc in IOS [UIApplication sharedApplication].statusBarHidden=hidden; Don't seem to work at all.
user4951
  • 32,206
  • 53
  • 172
  • 282
0
votes
0 answers

State preservation and restoration in ios 7 with xcode 5

I am trying to implement the state preservation and restoration mechanism in my app for that I implemented the following two methods in appDelegate also given the restoration id to each of my viewController in storyboard, the problem I am facing…
0
votes
1 answer

BlackBerry using UIApplication with MainScreen

I am trying to add a Browser Field onto my Main Screen. Currently, I have: public class BrowserFieldDemo extends UiApplication { private MainScreen _browserScreen; private BrowserField _bf2; private BrowserFieldConfig _bfConfig; public…
littleK
  • 19,521
  • 30
  • 128
  • 188
0
votes
1 answer

POST request without NSURLConnectionDelegate

I would like to send POST request but without using delegate. I have to have everything in a block. I'm also didn't want to use AFNetworking for this simple task. Why? I have only one request in my app and doesn't feel like including 3-party library…
Jakub
  • 13,712
  • 17
  • 82
  • 139
0
votes
1 answer

UIApplication openURL does not point to the correct destination in iOS7

I have an application that after a button click sends the client to the AppStore in order to download an new app. This is done with the following code: [[UIApplication sharedApplication] openURL:[NSURL…
cateof
  • 6,608
  • 25
  • 79
  • 153
0
votes
1 answer

Open image from ALAsset representation in default Photos app

How can I open an image obtained from the Assets Library in the default 'Photos' app on iPhone? Ideally this should work without temporally storing a second instance of the image in my app's document folder. I tried the following but there is no…
0
votes
2 answers

Bypass UABaseAppDelegateSurrogate for my custom UIApplicationDelegate

In my iOS app, I would like to retrieve a reference to my app delegate using [[UIApplication sharedApplication] delegate], however this is returning an instance of class UABaseAppDelegateSurrogate instead of my custom UIApplicationDelegate class. I…
0
votes
1 answer

perform cleanup task while going to background in iOS

I have to perform a long running clean up operation while application going into background. As the clean up operation is a network transaction and will take more than 5 seconds I am using beginBackgroundTaskWithExpirationHandler: API and everything…
0
votes
1 answer

Cancelling local notification on specified date

I have problem with even inventing the posible solution for this problem. My app needs to crate some objects of UILocalNotification with interval but if I set interval to be NSMinuteCalendarUnit if will bother me every minute until I cancel this…
cojoj
  • 6,405
  • 4
  • 30
  • 52
0
votes
0 answers

Opening URL in youtube app does not work the first time

In my app, I open up a youtube video like such: NSURL *youtubeURL = [NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]]; [[UIApplication sharedApplication] openURL:youtubeURL]; When I do this and I have the…
evenodd
  • 2,026
  • 4
  • 26
  • 38
0
votes
2 answers

iOS APN badge only going up to 3

So I have push notifications working perfectly except that the badge notification is only ever going up to 3 and then, even though it shows those notifications, the badge number doesn't go above that. Here is badge register and clear code on launch…
0
votes
4 answers

How i can know what device i have?

I have two storyboard with size for iphone 5 and size for iphone 4. All this device have 6 IOS. So i have my code for check version of IOS ... - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary…
Genevios
  • 1,115
  • 1
  • 16
  • 29
0
votes
1 answer

Objective-C Background task UIBackgroundTaskIdentifier duplicated

I have a background task that stop a streamer after 30 minutes as follows: - (void)applicationDidEnterBackground:(UIApplication *)application { bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ …
Mutawe
  • 6,464
  • 3
  • 47
  • 90