uiapplication

Accessing the Settings app from your app in iOS 8?

强颜欢笑 提交于 2019-11-27 00:54:05
问题 Is it possible to access the settings app from your own app via a button or whatever it may be in iOS 8. I heard that it got decrepitude in iOS 5, is that true? If not did the method change in iOS 8? If there is not other way to do this what would be the best way to work around it? 回答1: As of iOS 8, it is possible to take a user from your app directly into the Settings app. They will be deep linked into your app's specific Settings page, but they can back out into the top level Settings

Can an iOS App Switch to Safari Without Opening a Page?

半世苍凉 提交于 2019-11-26 22:49:06
问题 I know that my app can open a particular URL in Safari by doing something like this: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.example.com/"]]; but, is there any way to have my app switch over to Safari without opening a URL? I'd like to switch to Safari, but let it keep showing whatever page it had open the last time the user looked at it. 回答1: Unfortunately no, unless you can figure out how to launch an app by bundle id in a non-jailbroken environment.

openURL from App Extension

跟風遠走 提交于 2019-11-26 20:56:07
问题 On iOS 8 beta 2 it should be possible to use openUrl from app extension as written into the release notes: however when I try to use this API (on Xcode 6 beta 2) I get the following error: Beta 2 really fixed this issue or not? 回答1: you may use this code: [self.extensionContext openURL:url completionHandler:^(BOOL success) { NSLog(@"fun=%s after completion. success=%d", __func__, success); }]; the API document: openURL:completionHandler: you could also refer to this question: openURL not work

How can I find out whether the user pressed the Call or the Cancel button when making a call from my app?

雨燕双飞 提交于 2019-11-26 20:43:38
问题 I need to return to my app after making a call from my app, so I use this code: NSURL *url = [NSURL URLWithString:@"telprompt://123-4567-890"]; [[UIApplication sharedApplication] openURL:url]; When the user presses a button to execute this code, an alert is shown with 2 buttons, "Call" and "Cancel". How can I find out if the user pressed the "Call" button? 回答1: This isn't perfect, but you could identify that "call" was pressed instead of "cancel" by listening for the

UIApplication sharedApplication - keyWindow is nil?

此生再无相见时 提交于 2019-11-26 16:58:12
问题 I want to convert a CGPoint from my UIView to UIWindow coordinates and have realized that UIApplication keyWindow is always nil; why is this? I have tried the convertPoint:toView: method from UIView. Please see this sample code I tried in the view controller in a template of Xcode (View application): - (void)viewDidLoad { [super viewDidLoad]; UIView *test = [[UIView alloc] initWithFrame:CGRectMake(40,40,250,250)]; [test setBackgroundColor:[UIColor redColor]]; [self.view addSubview:test];

How to resolve: 'keyWindow' was deprecated in iOS 13.0

跟風遠走 提交于 2019-11-26 12:26:51
问题 I\'m using Core Data with Cloud Kit, and have therefore to check the iCloud user status during application startup. In case of problems I want to issue a dialog to the user, and I do it using UIApplication.shared.keyWindow?.rootViewController?.present(...) up to now. In Xcode 11 beta 4, there is now a new deprecation message, telling me: \'keyWindow\' was deprecated in iOS 13.0: Should not be used for applications that support multiple scenes as it returns a key window across all connected

What describes the Application Delegate best? How does it fit into the whole concept?

寵の児 提交于 2019-11-26 10:53:45
问题 I think to know what the App Delegate does. It has some nice methods like -applicationDidFinishLaunching which will be called when the app has finished launching, and so on. But what\'s that actually? Is that some object instantiated in the UIApplicationMain function? And how does it work that every class in my app has access to that App Delegate object? Is there any good graph on the net that visualizes these relationships? 回答1: In Cocoa, a delegate is an object that another object defers to

How do I prevent the iPhone screen from dimming or turning off while my application is running?

百般思念 提交于 2019-11-26 10:12:36
问题 I\'m working on an app that requires no user input, but I don\'t want the iPhone to enter the power saving mode. Is it possible to disable power saving from an app? 回答1: Objective-C [[UIApplication sharedApplication] setIdleTimerDisabled:YES]; Swift UIApplication.shared.isIdleTimerDisabled = true 回答2: In swift you can use this as UIApplication.sharedApplication().idleTimerDisabled = true 回答3: Swift 3: UIApplication.shared.isIdleTimerDisabled = true 回答4: I have put this line of code in my view

-[UIApplication delegate] must be called from main thread only

Deadly 提交于 2019-11-26 08:22:58
问题 This warning leads to a serious problem cause I really can\'t call the delegate outside of the main thread using Xcode 9 beta 2. Strange thing is that this was working when I was using Xcode 8.3.3. Also I thought it would only be good practice to call delegates from main thread only, isn\'t it? So why is this causing the app to crash now? 回答1: Just call it from the main thread like this. dispatch_async(dispatch_get_main_queue(), ^{ [[UIApplication delegate] fooBar]; }); Reaching out to your

Adding view on StatusBar in iPhone

五迷三道 提交于 2019-11-26 03:04:01
问题 Is it possible to add a UIView on the staus bar of size (320 x 20)? I don\'t want to hide the status bar, I only want to add it on top of the status bar. 回答1: 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