appdelegate

Call a method from AppDelegate - Objective-C

二次信任 提交于 2021-02-07 05:16:32
问题 I was trying to call an existing method of my ViewController.m from AppDelegate.m inside the applicationDidEnterBackground method, so I found this link: Calling UIViewController method from app delegate, which told me to implement this code: In my ViewController.m -(void)viewDidLoad { [super viewDidLoad]; AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; appDelegate.myViewController = self; } In my AppDelegate: @class MyViewController; @interface AppDelegate :

Swift - adding Subview in AppDelegate

て烟熏妆下的殇ゞ 提交于 2021-01-29 18:55:02
问题 I have a problem with revealingSplashView. I want it to be shown every time the app launches but it is not being displayed because I have to add it as a Subview but how can I do that inside AppDelegate ? I tried this but it is not working: class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? let revealingSplashView = RevealingSplashView(iconImage: UIImage(named: "zauberstab")!, iconInitialSize: CGSize(width: 120, height: 120), backgroundColor: .white) func application

Swift / iOS: How to pass data from AppDelegate to ViewController label?

情到浓时终转凉″ 提交于 2021-01-29 11:07:18
问题 I've got a (very) basic Universal Links test program that correctly launches from a link to the associated domain. It prints the received URL to the debug console. in AppDelegate.swift: func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { // First attempt at handling a universal link print("Continue User Activity called: ") if userActivity.activityType ==

Programmatically assign view controller to tab bar controller

夙愿已清 提交于 2021-01-28 07:08:21
问题 I am fairly new to swift and am trying to create a movie database application using TMDB from Apiary. I have created the layout of the view controllers for one category. However, I am planning to have multiple categories, the but only difference between them is the data I retrieve from the API. For example "now_playing" key gets the now playing list and the "top_rated" key gets the top rated list of movies. When I was initially doing this I created the tab bar controller in AppDelegate.swift

What's the equivalent of app delegate file for apple watch app?

余生长醉 提交于 2021-01-27 17:19:48
问题 I want to set the initial view controller for the watch app base on different type of notification received on the watch. But I don't know where's to set it. This is the answer for an iOS app Multiple entry points to a storyboard 回答1: watchOS 2 WKExtensionDelegate is the equivalent of the app delegate, where you can: respond to actionable notifications and manage Handoff transitions. You also use the delegate to respond to life-cycle events, such as the activation and deactivation of your app

Change WebView url from AppDelegate

泪湿孤枕 提交于 2021-01-19 06:17:12
问题 I'm receiving notifications from Firebase in the AppDelegate class. This notification contains a String named "notif_url". I've put this value in a var named "desired_url" and now I need to change my WebView url with the "desired_url" value. But I can't access to the webview to change it url like this : @IBOutlet weak var my_web_view: UIWebView! func load_url(server_url: String){ let url = URL(string: server_url); let request = URLRequest(url: url!); my_web_view.loadRequest(request); } load

Accessing AppState in AppDelegate with SwiftUI's new iOS 14 life cycle

孤者浪人 提交于 2020-12-12 05:12:32
问题 I'm using SwiftUI's new app lifecycle coming in iOS 14. However, I'm stuck at how to access my AppState (single source of truth) object in the AppDelegate . I need the AppDelegate to run code on startup and register for notifications ( didFinishLaunchingWithOptions , didRegisterForRemoteNotificationsWithDeviceToken , didReceiveRemoteNotification ) etc. I am aware of @UIApplicationDelegateAdaptor but then I can not e.g. pass an object through to the AppDelegate with a constructor. I guess the