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

UILocalNotification doesn't show text after pressing home button

I use this code to create local notification: UILocalNotification *notification=[[UILocalNotification alloc]init]; notification.soundName = @"new_friend_request.mp3"; notification.repeatInterval = 0; …
Paul T.
  • 4,938
  • 7
  • 45
  • 93
0
votes
2 answers

UIApplication sendEvent not working with popViewControllerAnimated

I'm trying to pop the current view controller from navigation controller. I want to do this from a subview that's buried pretty far down the view hierarchy. In my UIView subclass, I have a method: - (void)back { NSLog(@"View should pop…
zakdances
  • 22,285
  • 32
  • 102
  • 173
0
votes
2 answers

UILocalNotification adding and removing

After my user logs in the app pulls down a list of their meetings and adds them as UILocalNotification. Each time the user launches the app and logs in this happens. Which of the following is better "practice" when it comes to doing this over and…
random
  • 8,568
  • 12
  • 50
  • 85
0
votes
1 answer

Error when selecting photo when calling ABNewPersonViewController in iPad

I managed to push an ABNewPersonViewController to my navigation controller. However I encountered this error when I'm selecting "Add photo" -> "Choose Photo": * Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation',…
0
votes
1 answer

Is this even possible in iOS 5.1? Programmatically send user to maps via a UIButton (+action)?

I'm trying to use NSURL to send the user to maps with a address from my db. And I want to do this in an action within a UIButton, like I do for tel, mail and web. Like this; - (IBAction)restActionWeb:(UIButton *)sender { NSString *urlString =…
Mac
  • 111
  • 1
  • 11
0
votes
1 answer

Application Did Open from background iPhone

How can I determine when myApp is opened even when it is already opened in the background? Your help is greatly appreciated.
atomikpanda
  • 1,845
  • 5
  • 33
  • 47
0
votes
1 answer

UIApplication openURL can not open a url

I'm trying to implement a job search App. The results are shown to the user in a UITableView. When a user clicks on a cell, it should open the original Job announcement. To do this, i implemented the following method: - (void)tableView:(UITableView…
Zer0
  • 113
  • 10
0
votes
1 answer

Unused parameter shows error

I am new to objective C . i have created an ARC enabled application and modified build settings like Treat warning as error - YES and unused parameter - YES in Apple LLVM compiler 3.0 warning category in build setting. so in app Delegate file, UI…
0
votes
1 answer

How can the user open Maps from a table view cell in my App

Im trying to open Maps from my App from a table view cell, I know I need this code in my AppDelegate.m file: UIApplication *app = [UIApplication sharedApplication]; [app openURL:[NSURL…
0
votes
2 answers

Propagating touches from UIApplication in a custom manner

Is it possible to propagate touches from shared application object to a custom view which has not actually received touches and somewhere at the back of the top view? Assume that I can't use my top view to track touches.
cocoatoucher
  • 1,483
  • 3
  • 17
  • 22
0
votes
1 answer

How to restore status bar correctly?

I am making an app that requires the status bar to be hidden on one screen, but I then want it to come back on when the user goes back to the previous screen. I am using [[UIApplication sharedApplication] setStatusBarHidden:NO];, which works, but…
cory ginsberg
  • 2,907
  • 6
  • 25
  • 37
0
votes
2 answers

How to receive significant location changes on all application instead of only one view?

I'm new to iOS programming and I need to implement a location aware application. I can already use the significant location changes service, however when I leave my view it stops receiving new updates. If I enter background on that view I still get…
Gust
  • 195
  • 1
  • 15
0
votes
2 answers

Issue when hiding the status bar in landscape mode iphone

In my iPhone application, the default orientation throughout the app is Landscape mode. I wanted to hide the status bar, so I used [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; in the appDelegate.…
Mithun
  • 459
  • 1
  • 10
  • 32
0
votes
1 answer

Is it important to close BackgroundTaskWithExpirationHandler

I start a BackgroundTaskWithExpirationHandler when the application waken up by significant change location update. is it important to close the task as below: if (bgTask != UIBackgroundTaskInvalid) { [[UIApplication sharedApplication]…
user836026
  • 10,608
  • 15
  • 73
  • 129
0
votes
1 answer

Using invokeLater( ) in UiApplication

Can i include my try catch block with invokeLater statement in UiApplication for blackberry. What is the exact purpose of using an invokeLater mothod.And how is it to be invoked? Here is the code UiApplication.getUiApplication().invokeLater(new…
learning_fly
  • 382
  • 1
  • 2
  • 11