uiapplication

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

只愿长相守 提交于 2019-11-29 07:59:57
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 scenes How shall I present the dialog instead? This is my solution: let keyWindow = UIApplication.shared

Need clarification about UIApplicationState

坚强是说给别人听的谎言 提交于 2019-11-28 23:22:17
I need your help in clarifying my understanding of the various states of an app. I am going to state my interpretation - but please feel free to correct me. 1) App is launched and running in the foreground: state = UIApplicationStateActive 2) User pushes home button: state = UIApplicationStateBackground (????). Debug stmt in my app shows it to be Active 3) User double-taps Home and kills the app: state = UIApplicationStateInactive If the value for case 2 is indeed Active, then when is the value set to Background? My location-based app relies on this values to take appropriate action for the

Open Url hosted using POST method in Safari using sharedApplication openURL method

一曲冷凌霜 提交于 2019-11-28 23:21:09
问题 I have a situation in which i am using POST method to host a url in safari browser in simulator. The web page is opened in safari after launching my iOS app in simulator. To launch safari i have used [[UIApplication sharedApplication] openURL: ... The post method is as follows: NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://***some client url***.jsp"]]; NSString *post = [NSString stringWithFormat:@"username=%@&password=%@", userName, password

Proper use of UIApplicationMain

纵然是瞬间 提交于 2019-11-28 23:17:14
问题 I have decided to load my views programmatically, so putting: int ret = UIApplicationMain(argc, argv, nil, nil); Would not work. I do have a ViewController and an AppDelegate, though. What would be the proper use of UIApplicationMain to use a ViewController and an AppDelegate. PS I am NOT using XCode or Interface Builder, I am developing on the toolchain. 回答1: This function is declared as int UIApplicationMain ( int argc, char *argv[], NSString *principalClassName, NSString *delegateClassName

How does Booking.com close their app programmatically?

≯℡__Kan透↙ 提交于 2019-11-28 22:58:56
问题 I just saw this trick the Booking.com app does to let you change the application's language: I'm not aware of any technique to programmatically close an iOS app (and it's also forbidden by Apple's guidelines, but let's "pretend" that my boss wants me to do this). How do they do it? I've tried exit(0) but it immediately quit like when the process crashes, while their app animates to the home screen normally. Is there maybe a private URL scheme that opens the home screen? 回答1: You can try //

Can i have a single NSMutableArray in my multiple views application?

≯℡__Kan透↙ 提交于 2019-11-28 12:25:30
问题 I have a navigational based application which has multiple views. Is it possible to use one single NSMutableArray for the whole applicaiton? Can i add objects to that NSMutableArray in one view and then remove object from the same NSMutableArray from some other view? I tried myappAppDelegate *appDelegate = (myappAppDelegate *)[[UIApplication sharedApplication] delegate]; but it gives me null when i try to access appDelegate's array. If anyone can give me any idea or helping link or tutrorial.

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

Accessing the Settings app from your app in iOS 8?

回眸只為那壹抹淺笑 提交于 2019-11-28 05:18:33
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? 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 screen. If you're also supporting iOS 7 you'll need to check first if a specific string constant is present.

UIApplication sharedApplication - keyWindow is nil?

送分小仙女□ 提交于 2019-11-27 23:26:13
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]; CGPoint p = CGPointMake(100, 100); CGPoint np; np = [test convertPoint:p toView:[[UIApplication

Differentiate between screen lock and home button press on iOS7

人走茶凉 提交于 2019-11-27 22:17:11
I need to do something in applicationDidEnterBackground . But I need to differentiate which user action causes the "enter background": screen lock or home button press. I was using this code, which is from this post - How to differentiate between screen lock and home button press on iOS5? : UIApplicationState state = [application applicationState]; if (state == UIApplicationStateInactive) { NSLog(@"Sent to background by locking screen"); } else if (state == UIApplicationStateBackground) { NSLog(@"Sent to background by home button/switching to other app"); } It works fine on iOS6. but on iOS7