uiapplication

How to get the name of the running application in iOS

五迷三道 提交于 2019-11-30 02:33:04
If the application name under the icon on the home screen is "My Awesome App" how do you get that string within the application at runtime? David Dunham I’d try [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]; although presumably you know your own app’s name and can just use it… Swift 3 & 4 Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String ?? "" Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String ?? "" Swift 2.2 NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleName") NSBundle.mainBundle().objectForInfoDictionaryKey(

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

自作多情 提交于 2019-11-30 02:26:38
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]; NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; [request

Proper use of UIApplicationMain

允我心安 提交于 2019-11-30 02:24:55
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. This function is declared as int UIApplicationMain ( int argc, char *argv[], NSString *principalClassName, NSString *delegateClassName ); Since you did not subclass UIApplication, pass nil to the 3rd argument. But you have a custom

How does Booking.com close their app programmatically?

别说谁变了你拦得住时间么 提交于 2019-11-30 02:05:51
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? You can try // after change language dim display and follow it with this snippet DispatchQueue.main.asyncAfter(deadline: .now

how to get my UIWindow using UIApplication?

一笑奈何 提交于 2019-11-30 01:14:01
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 so I changed nothing, just trying to get the window Please help me to get this object If your main

Open Gmail app from my app

若如初见. 提交于 2019-11-29 23:35:35
I'm trying to send an email from my app. But what I want is if user is having Gmail app on his/her phone, then mail should be sent using it. If Gmail app is unavailable then the user should be redirected to Mailbox. So how can I know if user contains Gmail app and how can I redirect user to it. You need to use custom URL Scheme. For gmail application its: googlegmail:// If you want to compose a message there you can add more parameters to this URL: co?subject=Example&body=ExampleBody You can determinate if any kind of application is installed using this code (just replace customURL obviously

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

被刻印的时光 ゝ 提交于 2019-11-29 20:34:56
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 output {{0, 20}, {320, 460}} As you can see, bounds gives the correct y origin (0 starts from right

When should I release [[UIApplication sharedApplication] delegate] object?

有些话、适合烂在心里 提交于 2019-11-29 18:10:31
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 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 application delegate's lifecycle, not your responsibility. EDIT as @Goz points out, you should release it if at

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

◇◆丶佛笑我妖孽 提交于 2019-11-29 17:56:17
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. Thanks in advance. If you are having multiple views in your application, and in that case you want to

Launch Google maps app from iPhone application.

心不动则不痛 提交于 2019-11-29 15:18:08
问题 I'm trying to launch google maps from my iPhone application. The launching part works fine but since the iPhone 3.1 update (i think it was around this time) I get a zoomed out map of the US and Canada rather than zoomed in on my current location. Everything worked fine originally but sometime around the update things stopped working correctly. Here is the string I've been using. This works on my partners phone with iOS 3.0 and our iPod with iOS 2.2.1 but on my phone with iOS 3.1 shows a