uiapplicationdelegate

Keep a UIView or UIViewController on top of all others

北慕城南 提交于 2019-11-30 06:01:35
问题 I am subclassing UIApplication to intercept and display touches in my TouchDisplay view. I would like to extend the Application, Window, Delegate or Main ViewController in order to keep my TouchDisplay view on top of all other views. As my and most other applications work, views and controllers are added and removed all the time. I figure the correct answer will be able to deal with these additions and removals and stil keep the TouchDisplay view on top. Thanks for your help, Joe 回答1: Here

Is applicationWillResignActive ever called before didFinishLaunchingWithOptions ends?

谁都会走 提交于 2019-11-30 05:30:51
Can a scenario happen where applicationWillResignActive: will be called before application:didFinishLaunchingWithOptions: ends ? Basically, can I count on application:didFinishLaunchingWithOptions: to always be done before applicationWillResignActive is triggered for the first time? Apple's iOS App Programming Guide in the "App States and Multitasking" Section, indicates applicationWillResignActive: is called as part of your application's handling of events through processing the run loop, which only begins after application:didFinishLaunchingWithOptions: has finished. Furthermore, application

How to detect if code is running in Main App or App Extension Target?

南笙酒味 提交于 2019-11-29 21:23:11
Does anyone know how you detect from within your code if you're running inside an App Extension? I have an app which shares classes between an app and an extension. The app code uses [UIApplication sharedApplication] but this isn't available from within an extension, so it won't compile saying: 'sharedApplication' is unavailable: not available iOS (App Extension) So I need a way to detect that I'm in the extension and use an alternative to sharedApplication if that's the case. You can use a preprocessor macro: In the project settings use the dropdown in the topbar to select your extension

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

有些话、适合烂在心里 提交于 2019-11-29 18:10:31
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 Don't. Never release your application delegate - it is managed automatically by the OS. If you look in your app's main.m file, you'll see some code that initializes an instance of UIApplication that represents your app - it is its responsibility to manage the application delegate's lifecycle, not your responsibility. EDIT as @Goz points out, you should release it if at

Why not enforce strict singleton application delegate object to use in NIBs?

北战南征 提交于 2019-11-29 15:42:40
I just ran myself round in circles, all coming down to having instantiated an app delegate object in a secondary NIB that wasn't the NSMainNibFile . Amazing how having two app delegates kicking around means you have separate managedObjectContexts . Here's a thought-- could I make my application delegate class a singleton? And safely instantiate it in more XIBs? What would that break? Also, there are some mentions on stackoverflow that [[UIApplication sharedApplication] delegate] is a "singleton" but it doesn't appear that UIApplicationDelegate protocol guarantees that, nor is the superclass

Get Apple's remote push notifications even after app terminates

走远了吗. 提交于 2019-11-29 15:41:28
I am developing an iOS app which receives apple's remote push notifications at a particular time interval. The notifications are received successfully when app is active as well as when app is in background. But when app is terminated from app switcher/dock, notifications are not received until the app is started again. I have tried following code to keep app alive in background. This same code is implemented in applicationWillTerminate: method, but it did not work. __block UIBackgroundTaskIdentifier bgTask ; UIApplication *app = [UIApplication sharedApplication]; bgTask = [app

UIApplicationBackgroundRefreshStatusDidChangeNotification usage without corresponding delegate method

本小妞迷上赌 提交于 2019-11-29 15:23:16
问题 I feel that UIApplicationBackgroundRefreshStatusDidChangeNotification introduced in iOS 7 is of little use without supporting UIApplication delegate method. Because, the app is not notified when user has switch ON the background refresh state for my app. This is my notification handler... - (void)applicationDidChangeBackgroundRefreshStatus:(NSNotification *)notification { NSLog(@"applicationDidChangeBackgroundRefreshStatus with notification info = %@ and refresh status = %d", notification,

Counterpart to -application:openURL:sourceApplication:annotation:

南楼画角 提交于 2019-11-29 11:49:32
问题 iOS SDK 4.2 includes a new UIApplicationDelegate method called application:openURL:sourceApplication:annotation:. It is a replacement for application:handleOpenURL: and offers more information about the calling application: not only do we get the bundle identifier of the calling app, but also, in the annotation argument, A property-list object supplied by the source application to communicate information to the receiving application. Great, this should offer a lot of opportunities for a more

App delegate methods aren't being called in iOS 13

二次信任 提交于 2019-11-28 21:25:54
问题 I am using Xcode 11 and building an app for iOS 13. In a new project I created in Xcode some of the UIApplicationDelegate methods were missing so I added them back into the app delegate file. The new template for a "Single View App" project was missing the methods. The problem is that none of the delegate methods are getting called except -application:didFinishLaunchingWithOptions: . Here is my app delegate: @implementation AppDelegate - (BOOL)application:(UIApplication *)application

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

左心房为你撑大大i 提交于 2019-11-28 12:14:46
问题 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 回答1: Don't. Never release your application delegate - it is managed automatically by the OS. If you look in your app's main.m file, you'll see some code that initializes an instance of UIApplication that represents your app - it is its responsibility to manage the