appdelegate

How to pass data from AppDelegate to ViewController?

陌路散爱 提交于 2019-12-06 08:38:34
I'm using Safari to browse a webpage. After I click a button on this page, my Ipad will launch my app. So I implement the method - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url in the AppDelegate.m . - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{ if (!url) { return NO; } NSString *URLString = [url absoluteString]; self.paramArray = [URLString componentsSeparatedByString:@"@"]; NSLog(@"%d",[self.paramArray count]); for (int i = 1; i < [self.paramArray count]; i++) { NSLog([self.paramArray objectAtIndex:i]); } return YES; } The url I used

Swift: visual glitches when presenting a Main and Alternative (login/onboarding) Flow? [closed]

痴心易碎 提交于 2019-12-06 07:13:47
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I've got an App that requires the person to sign in or create an account the first time the App is launched. (Although this is not generally recommended, this is quite a specific use case.) Furthermore, if they are already signed in, when the App is updated I'd like to show them a

Aassigning a value to a view controller from AppDelegate.swift

岁酱吖の 提交于 2019-12-06 05:28:54
I try to assign a value to a view controller from AppDelegate.swift without success. My controller is named DestinationsViewController , and its id in Main.storyboard is destinationsID . DestinationsController is embed in a Navigation Controller. The objet I want to change is named "label". This is the code: if let destinationsViewController = storyBoard.instantiateViewControllerWithIdentifier("destinationsID") as? DestinationsViewController { if let label = destinationsViewController.label{ label.text = "Super!" } else{ println("Not good 2") } } else { println("Not good 1") } Unfortunately, I

Configure deep links in swift?

孤人 提交于 2019-12-06 02:18:06
问题 So I have an app written in swift that I would like to use deep links for. A user would click on one that in the route of the URL had different pieces of information such as the id of the post or the number of likes it has or something like that. I understand that you put this in the AppDelegate: func application(application: UIApplication,openURL url: NSURL,sourceApplication sourceApplication: String?,annotation annotation: AnyObject?) -> Bool { println(url.host as String!) return true } And

supportedInterfaceOrientationsForWindow in Swift 2.0

徘徊边缘 提交于 2019-12-05 23:38:16
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask { return UIInterfaceOrientationMask.Portrait.rawValue.hashValue | UIInterfaceOrientationMask.PortraitUpsideDown.rawValue.hashValue } That used to work in Swift 1.2 however the return line is now throwing this error: Binary operator '|' cannot be applied to two 'UIInterfaceOrientationMask' operands I am able to get to work with just 1 return value with the new type but I cannot get it to pipe the second orientation I need. This 'works' func application

How to hold splashscreen until process in app delegate is over?

自闭症网瘾萝莉.ら 提交于 2019-12-05 22:34:37
In app delegate I put some func, I want the splashscreen waiting till the appdelegate finished its func. Now, my app immediately run initial view controller func and app delegate func together. func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. let email = NSUserDefaults.standardUserDefaults().stringForKey("userEmail") if let email = email { reLogin() }else{ buildNavigationDrawer() }// I want this execute first and run the initial view controller's after return

How to share iAd banner between views using AppDelegate

末鹿安然 提交于 2019-12-05 12:20:50
I am looking to implement iAd in my app. So far I have managed to get them showing/dismissing correctly in each view using the below. App Delegate: import UIKit import iAd @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? var adBannerView = ADBannerView() View Controller 1: import UIKit import iAd class HomeScreenViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, ADBannerViewDelegate { let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate //Creates reference to the AppDelegate override func

iPhone Objective-c detect Screen Lock

a 夏天 提交于 2019-12-05 09:58:11
I'm new to make iPhone App with Objective-c I want to make the App which sends a notification when iPhone screen is locked(Pressed Lock button) How can I make this app? I'm trying to make it using "applicationWillSuspend", but /*----------------------------------------*/ - (void)applicationWillSuspend { NSLog(@"WillSuspend"); } /*----------------------------------------*/ This code doesn't work I'm not sure when applicationWillSuspend is called Please, give me some knowledge #import "AppDelegate.h" #import <notify.h> @interface AppDelegate () @end @implementation AppDelegate - (BOOL

UINavigationBar set custom shadow in AppDelegate.swift

瘦欲@ 提交于 2019-12-05 06:42:02
I want to set some shadow to the bottom of my UINavigationBar for the whole application. Here is what I've tried but it doesn't work: func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { UINavigationBar.appearance().layer.shadowOffset = CGSizeMake(0, 3) UINavigationBar.appearance().layer.shadowRadius = 3.0 UINavigationBar.appearance().layer.shadowColor = UIColor.yellowColor().CGColor UINavigationBar.appearance().layer.shadowOpacity = 0.7 } Please, tell me how can I do this? UPDATE: Solved by subclassing from

Access a view controller from appdelegate using storyboard

巧了我就是萌 提交于 2019-12-05 02:24:17
问题 I have followed this Ray Wendelich Tutorial RayWenderlichTutorial Tabbarcontroller using storyboards Just see the storyboard image. Ray is accesing 'playersViewcontroller using the below code' UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController; UINavigationController *navigationController = [tabBarController viewControllers][0]; PlayersViewController *playersViewController = [navigationController viewControllers][0]; When I'm trying to access