uiapplication

Get Application's main window

女生的网名这么多〃 提交于 2019-12-04 23:40:31
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? Espresso 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 . I'm not 100% sure this works in every case but this should work: UIWindow *mainWindow = [UIApplication sharedApplication]

iOS application runs after end of background task

走远了吗. 提交于 2019-12-04 20:55:16
I made custom voip application. Almost everything works nice; but time from time application is restarted. From crash log: Exception Type: 00000020 Exception Codes: 0xbad22222 Highlighted Thread: 4 SBUnsuspendLimit CryptTalkDev[24820] exceeded 15 wakes in 300 sec Highlighted thread call stack: Thread 4 name: com.apple.NSURLConnectionLoader Thread 4: 0 libsystem_kernel.dylib 0x35eab004 0x35eaa000 + 4100 1 libsystem_kernel.dylib 0x35eab1fa 0x35eaa000 + 4602 2 CoreFoundation 0x355d93ec 0x3554c000 + 578540 3 CoreFoundation 0x355d8124 0x3554c000 + 573732 4 CoreFoundation 0x3555b49e 0x3554c000 +

UIApplication openUrl not working with formatted NSString

孤人 提交于 2019-12-04 10:08:07
问题 I have the following code to open google maps: NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@, Anchorage, AK",addressString]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]]; But it doesn't work and there is no error. It just doesn't open. 回答1: URLWithString requires a percent-escaped string. Your sample url contains spaces which results in a nil NSURL being created. Additionally, the addressString may also contain characters

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

只谈情不闲聊 提交于 2019-12-04 02:01:58
This question already has answers here : Closed last year . -[UIApplication delegate] must be called from main thread only (2 answers) 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". I am working with CoreData while my app is in the background, but this is the first time I've seen this

How to use [[UIApplication sharedApplication] openURL:] open other app?

我怕爱的太早我们不能终老 提交于 2019-12-03 19:42:14
问题 I followed http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html instruction to open app1(GlassButton) within app2(FontTest). The open method of FontTest as following: -(void)open { BOOL res = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"glassbutton://"]]; if (res) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"glassbutton://"]]; } } The value of "res" is "YES", but nothing happen after openURL method be

how to get my UIWindow using UIApplication?

 ̄綄美尐妖づ 提交于 2019-12-03 18:44:10
问题 I have only one window and I tried UIWindow* mWindow = [[UIApplication sharedApplication] keyWindow]; but this returned nil. I also tried: UIWindow* mWindow = (UIWindow*)[[UIApplication sharedApplication].windows objectAtIndex:0]; But this raised an exception and the app closed, when I tried to print out [[UIApplication sharedApplication].windows count] It printed 0 Note: I am putting this in my only view controller's viewDidLoad method and this is completely a new iPad View Based Application

How to set custom font family as system font in ios application [duplicate]

↘锁芯ラ 提交于 2019-12-03 18:38:04
问题 This question already has answers here : Set a default font for whole iOS app? (17 answers) How can I change default font in ios dev [closed] (1 answer) Closed 6 years ago . I am working on an ios application in which i have to use custom fonts for UIs. I know how to integrate new custom fonts in application. For that i have Download font family files with .ttf extention. Add them to resource bundle. In info.plist file add with key Fonts provided by application. This custom fonts shows effect

How to get the actual [UIScreen mainScreen] frame size?

核能气质少年 提交于 2019-12-03 18:24:43
问题 I'm a bit annoyed. I have an app with the statusbar visible in the main window. Since I would like to setup my views and their frame sizes dynamically (perhaps the status bar takes up 40 pixels during a phone call, for example). I can do one of the two: [[UIScreen mainScreen] bounds]; [[UIScreen mainScreen] applicationFrame]; The really annoying this is these two output two different sets of values, each equally as useless. bounds will output: {{0, 0}, {320, 480}} while applicationFrame will

How did Vesper show users wallpaper without UIApplicationIsOpaque key?

◇◆丶佛笑我妖孽 提交于 2019-12-03 16:50:00
问题 An app named Vesper was updated for iOS 7 and shows the user's wallpaper on iOS 7. I have found that using UIApplicationIsOpaque key and UIBackgroundStyleLightBlur can show the users background but will not pass validation. Vesper passed validation and passed Apple. I did upload this question to the dev forums, but apple has taken it down. 回答1: Brent Simmons has written a blog post explaining it. It seems like they didn't use UIApplicationIsOpaque key. The Sidebar In 1.0 our sidebar menu

How to use UIApplication handleOpenURL Notifications

怎甘沉沦 提交于 2019-12-03 15:02:11
I am trying to handle UIApplication Notifications to get URL Schemes in current open view. I have tried several notifications but i don't know which object contains the URL Schemes. NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; //[nc addObserver:self selector:@selector(DocumentToDropboxDelegate) name:UIApplicationWillResignActiveNotification object:nil]; [nc addObserver:self selector:@selector(DocumentToDropboxDelegate) name:UIApplicationDidFinishLaunchingNotification object:nil]; Can someone pelase help me with this issue. As @Mike K mentioned you'll have to implement one