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

Where to handle event of UIApplication subview

While studying UIApplication, I find a way to add a view on top of all UIViewController. UIView *testView = [[UIView alloc] initWithFrame:CGRectMake(40,40,250,250)]; [testView setBackgroundColor:[UIColor redColor]]; [[[UIApplication…
Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300
1
vote
2 answers

Assign code blocks to a property objective c

I'm attempting to get Background App Refresh going in my iOS application. However, I'm having some trouble understanding code blocks. I've done some research on it, and would say I have a beginner's understanding so far. The method in question…
Salx
  • 579
  • 5
  • 21
1
vote
2 answers

Is it normal for Apple to reject an app for using UIApplication to disable screen lock?

I just had an app rejected because I have a user changeable setting which allows the user to disable screen lock via [UIApplication sharedApplication].idleTimerDisabled = YES; Apple says I used an undocumented API but it IS indeed documented here:…
Jackson
  • 3,555
  • 3
  • 34
  • 50
1
vote
2 answers

How can I launch app store from my application

Im trying to implement button which opens app store application from my app. I use this simple line of code, which opens safari but not app store application. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:…
Tankista
  • 1,685
  • 17
  • 26
1
vote
2 answers

UIApplication. Background execution for a fixed amount of time

So, i want my app to do background execution for only a fixed amount of time, this is in case the user does not manually stop the app, and the app therefore in theory could run in background forever(is that even possible?). I'm using the code below…
Anders
  • 719
  • 8
  • 22
1
vote
2 answers

User terminates app forcefully: Registering this event

In my app I use background services so the method applicationWillTerminate: will not get called when the user terminated the app. Instead the method applicationDidEnterBackground: gets called when the user pushed the app into to background and when…
freshking
  • 1,824
  • 18
  • 31
1
vote
2 answers

How to check if global dispatch queue empty?

in my app I am implementing my internet network with global dispatch queue and gcd. I want to set network indicator visible while there is network activity. here is my network block - > { [[UIApplication…
david
  • 157
  • 1
  • 1
  • 12
1
vote
1 answer

How do I implement web user session concept for iPhone native apps to auto-logout?

I would like to autologout my app incase if the user doesn't interact with it for five minutes just like web user session in websites. I tried all over the internet I couldn't find anything useful. I am beginner to this development. Any help is…
Rakesh patanga
  • 832
  • 9
  • 25
1
vote
1 answer

iOS: How to open my app files in safari

I need to open my files from documents folder in safari I tried using [UIApplication sharedApplication] openURL: type. I would like to open my local file from my app Eg:…
Rajesh Loganathan
  • 11,129
  • 4
  • 78
  • 90
1
vote
1 answer

How to open link in external browser in cocos 2d-x

I was opening link in cocos 2d-x (in Previous versions) like: CCApplication::sharedApplication()->openUrl("http://www.google.com"); A help from this link: https://github.com/cocos2d/cocos2d-x/pull/4893/files But in new version openUrl no more…
1
vote
2 answers

ios button mail to with subject

I have a button that is right now opening the mail application and adding a contact through a property I set up. How can I do this to also add a subject line through a property? - (IBAction)tourButton:(id)sender { [[UIApplication…
Packy
  • 3,405
  • 9
  • 50
  • 87
1
vote
2 answers

Wrong result for backgroundTimeRemaining from within UIApplicationDidEnterBackgroundNotification

I have looked into related topics which did not give correct answers. The following code is running from within an observer of UIApplicationDidEnterBackgroundNotification NSTimeInterval backgroundTimeRemaining = [[UIApplication…
ishahak
  • 6,585
  • 5
  • 38
  • 56
1
vote
1 answer

UIViewController inside UINavigationController Jumps down when application returns from background

When my app returns from background, the UIViewController jumps down the height of the UINavigationBar (44 pixels). Everything is being controlled through a story board using push segues. Even when I NSLog the frame of both the view controller and…
1
vote
1 answer

MBProgressHUD unable to change text if shown on window

I am using a MBProgressHUD and I need to show it on window as I want to add many full screen views. I set HUD with a text and when i change the text later, its not changing the text. HUD is a retained property of a singleton class. When i show it on…
NaXir
  • 2,373
  • 2
  • 24
  • 31
1
vote
1 answer

iPhone Google Maps app open from iOS App, only shows coordinates not location name.

In my iOS app, I'm opening google map app from inside the code. I can open it but when it launches, I can only see the coordinate of the location. Does it make any sense to anyone ? It must be location name or coordinate with location name. Anybody…
jenis
  • 36
  • 3