appdelegate

Swift - pushViewController from appDelegate, rootViewController.navigationController is nil

不打扰是莪最后的温柔 提交于 2019-11-27 12:14:14
问题 Having a problem following a few guides, specifically http://blog.originate.com/blog/2014/04/22/deeplinking-in-ios/ I'm setting the url scheme and it's working well to launch the app from another app, but passing in the host or url are not working as it seems it should. I'm using storyboards and interface builder for all the view layouts. The guide shows this openURL in appDelegate: -(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *

When do the appdelegate methods get called in relation to the view lifecycle methods of your initial view controller? [closed]

孤街浪徒 提交于 2019-11-27 11:00:51
问题 What is the sequence of methods that get called when your app loads, especially for these methods: applicationDidFinishLaunching viewDidLoad viewWillAppear applicationDidBecomeActive awakeFromNib 回答1: U could checkout this site http://www.cocoanetics.com/2010/07/understanding-ios-4-backgrounding-and-delegate-messaging/ & this flow chart of application. and check out this flow chart.... 来源: https://stackoverflow.com/questions/17498568/when-do-the-appdelegate-methods-get-called-in-relation-to

Controlling which view controller loads after receiving a push notification in SWIFT

半世苍凉 提交于 2019-11-27 09:52:04
问题 Once I receive a push notification and swipe to open it, it just opens my app and not the VC I want. So my question is how do I load the VC I want? I know if the app is open I would move the VC over to another inside the didReceiveRemoteNotification but how do I do it if the app isn't open? or if it is in background mode? Also I have TWO different push notifications, so therefore I need it to move ONE of TWO different VCs. How can I tell the difference between different push notifactions?

How to programmatically add a UITabBarController & UINavigationController in AppDelegate?

徘徊边缘 提交于 2019-11-27 08:52:16
问题 How to add a UINavigationController & UITabBarController programmatically in app delegate. 回答1: Don't forget in the AppDelegate.h file to add: @property (strong, nonatomic) UITabBarController *tabBarController; Below is the AppDelegate.m - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. self.tabBarController = [[UITabBarController alloc] init]; ViewController1 *VC1 = [

How to run timer thought the app entered background or is terminated

邮差的信 提交于 2019-11-27 08:45:16
问题 In my app I have a NSTimer, and a selector - (void)TimerCount . I also have a integer int CountNum , and every 0.01 second, it increases by 1 ( CountNum = CountNum + 1 ). Timer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(TimerCount) userInfo:nil repeats:YES]; And I want the timer to resume thought the app is terminated or it entered background. How can I do this? 回答1: If your application is terminated , you will not be able to continue processing. To operate

Swift - AVAudioPlayer, sound doesn't play correctly

萝らか妹 提交于 2019-11-27 07:17:26
问题 Because UILocalNotification is not being displayed while the application is in active stat, I'm trying to configure an UIAlertController and playing a little sound when it appears. I've no problem, in the AppDelegate , to handle the notification/create the alert. My problem concerns the sound. Indeed, it doesn't play correctly. Here is what I have so far : //... class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication,

How to present a splash/login view controller using storyboards

一笑奈何 提交于 2019-11-27 07:09:06
I've seen this question in various forms without a clear answer. I'm going to ask and answer here. My app needs to do work on startup... inits, a few network calls, login, etc. I don't want my main view controller working until that's done. What's a good pattern for doing this? Requirements: iOS5+, storyboards, ARC. the main vc's view cannot appear until the startup work is done. want a choice of transition styles to the main vc when the startup work is done. want to do as much layout as possible in storyboard. the code should be cleanly contained somewhere obvious. EDIT, July 2017 Since the

Getting location for an iOS app when it is in the background and even killed

女生的网名这么多〃 提交于 2019-11-27 06:54:05
问题 My app needs to get the user's location when app is active and when it's inactive and killed. When the user's location is near to a store the app has to send a local notification. I'm not sure what exactly is happening, but I'm not able to make my app get the location in the background and wakes it up when is killed. I have a location manager (singleton, used for boths cases whenInUse and Always), and I have both NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription defined

Swift – Instantiating a navigation controller without storyboards in App Delegate

情到浓时终转凉″ 提交于 2019-11-27 05:25:35
问题 I'm rebuilding an app without storyboards and the part of it that I'm having the most trouble with is navigating view-to-view programatically. Few things are written out there which don't use storyboards, so finding an answer for this has been tough. My problem is pretty simple. I have my ViewController and my SecondViewController and I want to push from the former to the latter. In AppDelegate : func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions:

iOS13 on Xcode 11 Black screen even after adding SceneDelegate and updating Info.plist

北城余情 提交于 2019-11-27 04:39:40
问题 I am currently getting a blank screen with Xcode 11, Target iOS 13.0 (the app works fine with all below versions iOS 12.1 till 12.4), I want to make my App work for both iOS users above 12.1 and also 13.0 currently getting blank screen despite adding the below SceneDelegate to my existing project and adding App Manifest file import UIKit import SwiftUI @available(iOS 13.0, *) class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? func scene(_ scene: UIScene,