UIApplication sharedApplication – keyWindow is nil?
This code was executed before [window makeKeyAndVisible]; which is inside the app delegate. So, no wonder why keyWindow was nil yet.
This code was executed before [window makeKeyAndVisible]; which is inside the app delegate. So, no wonder why keyWindow was nil yet.
In Cocoa, a delegate is an object that another object defers to on questions of behavior and informs about changes in its state. For instance, a UITableViewDelegate is responsible for answering questions about how the UITableView should behave when selections are made or rows are reordered. It is the object that the UITableView asks when … Read more
Objective-C [[UIApplication sharedApplication] setIdleTimerDisabled:YES]; Swift UIApplication.shared.isIdleTimerDisabled = true
Just call it from the main thread like this. Objective-C dispatch_async(dispatch_get_main_queue(), ^{ [[UIApplication delegate] fooBar]; }); Swift DispatchQueue.main.async { YourUIControlMethod() } Reaching out to your app delegate like this, is a hint that your architecture could use a little cleanup. You can call delegates from any thread you want. You only need to make sure … Read more
Yes, this is possible since iOS 10.3. First, you need to define all alternative icons in your Info.plist file, you can’t fetch them dynamically. In the example below we define 2 alternative icons: “de” and “fr”: <key>CFBundleIcons</key> <dict> <key>CFBundleAlternateIcons</key> <dict> <key>de</key> <dict> <key>CFBundleIconFiles</key> <array> <string>ic_de</string> </array> <key>UIPrerenderedIcon</key> <false/> </dict> <key>fr</key> <dict> <key>CFBundleIconFiles</key> <array> <string>ic_fr</string> </array> … Read more
You can easily accomplish this by creating your own window above the existing status bar. Just create a simple subclass of UIWindow with the following override of initWithFrame: @interface ACStatusBarOverlayWindow : UIWindow { } @end @implementation ACStatusBarOverlayWindow – (id)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { // Place the window on the correct level and … Read more
AS @Nix Wang’s ANSWER THIS IS NOT WORK IN IOS 10 WARNING: This method will not work for devices running iOS 5.1 and greater – See Hlung’s comment below. It’s possible that the path component has a different name than the actual section, but it’s also possible that you can’t currently access that section straight … Read more