uiapplication

Get Application's main window

百般思念 提交于 2019-12-06 18:09:40
问题 UIApplication has a method keyWindow , however if an alert view is showing then this returns the window of the alert view and not the main window of the application. How can I get the app's main window? 回答1: The UIApplicationDelegate usually has a reference to the "main window": [[[UIApplication sharedApplication] delegate] window]; Furthermore, UIApplication has an array of windows [[UIApplication sharedApplication] windows] . See the UIApplication Class Reference. 回答2: I'm not 100% sure

Launching Facebook and Twitter application from other iOS app

守給你的承諾、 提交于 2019-12-06 12:25:09
问题 Hey guys, I am still continuing to build my iPhone project and I am having trouble with launching the facebook application. First of all, I am assuming every SDK Xcode developer knows that the Facebook application doesn't have the facebook or twitter app in the simulation. Since I have a facebook page and a twitter account about my company, I can't seem to test to launch my facebook page from the facebook application or my twitter page from the twitter application because they are not there

iOS Background Fetch mode can be used to schedule some operation in the future that doesn't actually fetch remote data?

时光怂恿深爱的人放手 提交于 2019-12-06 11:26:02
I'm doing an app that requires to reschedule local notification on daily basis. I'm aware about the repeatInterval property, but repetitioon here is like each 2 days etc. I've seen silent notifications, but they can be used only with push notifications and due to some requirements I can't use that approach. Now the app works on the hypothesis that the user will open the app quite enough to reschedule those notifications. This hypothesis is fine and we all agree that will work, but I will be more confident, if it would be possible to reschedule them on daily basis without opening the app. I've

How to call (dialing) with “ * ” char in IOS?

£可爱£侵袭症+ 提交于 2019-12-06 02:39:53
I hope to call with * character. ex> *711313. Currently, I'm using this code: NSString *str = [NSString stringWithFormat:@"tel:%@", tmp]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]; I tested two cases: tmp = @"719929292"; //this is ok. make call. tmp = @"*7128282"; //app no reaction. not to call. How can I call with *(star character)? The star may have to be encoded for use in a URL. Try %2A instead of * . This replacement is not done by stringByAddingPercentEscapesUsingEncoding: since * is a valid URL

how to detect idle user in iphone-sdk

泪湿孤枕 提交于 2019-12-05 21:45:37
In my Application I want to call Logout Function if user is idle for certain amount of time how to accomplish this answer doesn't work for me iPhone: Detecting user inactivity/idle time since last screen touch if i subclass my app delegate class from UIApplication and implement - (void)sendEvent:(UIEvent *)event It gives me error *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'There can only be one UIApplication instance.' I can't find the other instance of UIApplication in my application so far i have done instead of @interface IdleAppDelegate :

UIApplication.delegate must be used from main thread only [duplicate]

怎甘沉沦 提交于 2019-12-05 17:15:55
问题 This question already has answers here : -[UIApplication delegate] must be called from main thread only (2 answers) Closed 2 years ago . I have the following code in my app delegate as a shortcut for working with CoreData in my other viewControllers: let ad = UIApplication.shared.delegate as! AppDelegate let context = ad.persistentContainer.viewContext However, I now get the error message: "UI API called from background thread" and "UIApplication.delegate must be used from main thread only".

openURL is not working when App is in background in iOS

别说谁变了你拦得住时间么 提交于 2019-12-05 12:14:15
I am trying to open one URL in Safari from my App when App is in background, below is my code [[UIApplication sharedApplication]openURL:[NSURL URLWithString:strURL]]; My App is hiting the above line during debugging, but not opening Safari with the given URL. It's not possible, You cannot launch another app from the background state. If app in background then you can't have any event for handle your app event from iPhone/iPad screen. You must have to wake up your app. You can use local notifications. 来源: https://stackoverflow.com/questions/25132931/openurl-is-not-working-when-app-is-in

Set status bar orientation in iOS 6.0 [duplicate]

你。 提交于 2019-12-05 12:04:44
Possible Duplicate: setStatusBarOrientation:animated: not working in iOS 6 In iOS 6.0, as AppDelegate by default extends UIRepsonder and not UIApplication there is no global sharedApplication object. Am I missing anything? I am trying to set status bar orientation using following and it doesn't seem to work anymore. I tested it on iOS 6.0 simulator. I know you can set status bar tint color from the plist settings but can anyone please tell me how to set status bar orientation programmatically in iOS 6.0? [[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait

Call using Skype.app via openURL:

旧巷老猫 提交于 2019-12-05 11:18:20
Does anybody know if it is possible open Skype.app to call phone via - (BOOL)openURL:(NSURL *)url UIApplication message? If it possible, what url a need pass to this message? Thanks Just for reference, this seems to have changed when multitasking support was added: starting at least with Skype 2.1.0, this URI works fine: skype:+33123456789?call By looking at Skype's Info.plist file (you can open it from the ipa file iTunes has downloaded), you can tell it has no URL registered, so you won't be able to call it from your application. You should look for a key called CFBundleURLTypes (you can

detect unacknowledged UILocalNotifications

柔情痞子 提交于 2019-12-05 06:09:21
It seems that didFinishLaunchingWithOptions:(NSDictionary *)launchOptions and didReceiveLocalNotification:(UILocalNotification *)notification are only triggered if the user acknowledges the UILocalNotification, for example by swiping the slider or touching the entry in iOS's Notification pull-down. Is there any way to tell that a UILocalNotification has gone off if the user ignores the UILocalNotification and re-enters the app by simply clicking on the app icon? I should mention that this really only applies to repeating notifications because the firing of non-repeating notifications can be