appdelegate

Root View Controller Swift

醉酒当歌 提交于 2020-02-08 09:15:36
问题 I have a function in my app delegate which appends an item to an array in my a file named ViewController.swift, and then I want to reload a tableview in that same file. I attempt to do so like so: let vc = ViewController() let navigationController = UINavigationController(rootViewController: vc) window!.rootViewController = navigationController println(vc.messages) //1 vc.messages.append(message.data.message as! String) //2 vc.MessageTableView?.reloadData() The lines numbered 1,2 are where I

Root View Controller Swift

99封情书 提交于 2020-02-08 09:14:44
问题 I have a function in my app delegate which appends an item to an array in my a file named ViewController.swift, and then I want to reload a tableview in that same file. I attempt to do so like so: let vc = ViewController() let navigationController = UINavigationController(rootViewController: vc) window!.rootViewController = navigationController println(vc.messages) //1 vc.messages.append(message.data.message as! String) //2 vc.MessageTableView?.reloadData() The lines numbered 1,2 are where I

Reload/refresh a scene after receive remote notification swiftUI

余生长醉 提交于 2020-02-06 08:44:40
问题 I have this problem. I'm receiving a notification from CloudKit using application:didReceiveRemoteNotification in AppDelegate. I'm able to receive the recordId, fetch it, and save it successfully. The problem is, the scene doesn't refresh. final class UserData: ObservableObject { @Published var items: [Item] = [] func saveFetchedItem(recordId: CKRecord.ID, reason: CKQueryNotification.Reason) { fetchAndSaveRemoteDataFromCloudKit(recordId: recordId, reason: reason, userData: self) } } in

Getting error Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT) when loading AVPlayer

和自甴很熟 提交于 2020-02-04 05:28:27
问题 I am trying to load an AVPlayer when I select a collectionViewCell, Here is my code in didSelectItem : func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { if let item = items?[indexPath.item] { showPlayer(item: item) } } func showPlayer(item: Item) { let playerLauncher = PlayerLauncher() playerLauncher.showVideoPlayer() let playerView = PlayerView() playerView.item = item playerView.setupPlayerView() } This is my PlayerLauncher file: class

Launching ViewController from AppDelegate

倾然丶 夕夏残阳落幕 提交于 2020-01-22 05:50:12
问题 I have a custom URL scheme and i want to open a certain ViewController which is not the root when i go to this URL. I have been able to do that and what remains is pushing this ViewController into the navigationController from the AppDelegate where i handle my URL like this : - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { if ([[url scheme] isEqualToString:@"njoftime"]) { NSDictionary

AppDelegate window initialisation does not have correct size

倾然丶 夕夏残阳落幕 提交于 2020-01-15 10:44:07
问题 I have an app in Xcode which I want to start without a storyboard, so I created a new window in AppDelegate: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let InitialViewController: SignViewController = SignViewController() let NavigationController: UINavigationController = UINavigationController(rootViewController: InitialViewController) self.window = UIWindow(frame: UIScreen.main.bounds) self

How to use the device token in method other than didRegisterForRemoteNotificationsWithDeviceToken?

冷暖自知 提交于 2020-01-11 11:08:46
问题 I got the device token through didRegisterForRemoteNotificationsWithDeviceToken method. I wanted to use the device token in another method. I tried it in this way, In didRegisterForRemoteNotificationsWithDeviceToken method: str = [NSString stringWithFormat:@"%@",deviceToken]; // str is the NSString which is declared in the appDelegate.h file as global variable In didReceiveRemoteNotification method: NSLog(@"Device Token : %@",str); When i do like this the Device Token is returning as "nosniff

iOS 13: Swift - 'Set application root view controller programmatically' does not work

旧城冷巷雨未停 提交于 2020-01-10 18:44:06
问题 I have following code in my AppDelegate.swift to setup root view controller for an iOS application. But it does not work. It follows Target structure (defined under General tab) and ignores this code. (Xcode 11, Swift 5.1, iOS 13) class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { window = UIWindow(frame: UIScreen.main.bounds)

How do we detect when control center on iOS 7?

笑着哭i 提交于 2020-01-04 08:26:18
问题 I am having an issue when the control center appears on iOS 7. Basically, the applicationDidEnterBackground is fired when the control center appears. However in my method, I would like to detect if it's just the control center opening or the notification center since I would treat the applicationDidEnterBackground differently in that state. Any help would be appreciated. 回答1: I just published a little UIWindow subclass that does exactly that. You simply subscribe to an NSNotification and can

application(_:url:options:) is never called

人走茶凉 提交于 2020-01-04 05:41:13
问题 Steps to reproduce: Create a new project with default settings in Xcode 11: Single View App / Swift / Storyboards. Add your Document Types and Imported UTIs. Result: My application appears in “Copy to...” menu (or “Open in...” if we use LSSupportsOpeningDocumentsInPlace ). It really launches the app. But this delegate method: application(_:url:options:) is never called. 回答1: In iOS 13 this method was replaced with a new UISceneDelegate method by default. Solution: If you don't need scenes,