Post

Replies

Boosts

Views

Activity

Reply to UISwitch-iOS 14-Swift: Programmatically added Switch doesn't work anymore
Hey andrew_holmes37, yep. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifier, for: indexPath) as! SettingsCell cell.textLabel?.text = social?.description cell.imageView?.image = UIImage(systemName: social!.image) cell.imageView?.tintColor = .systemBlue cell.contentView.isUserInteractionEnabled = false return cell }
Dec ’20
Reply to Swift: App in portrait mode - How can I set landscape mode only for one Controller/View/Page?
I've developed the following solution: The Device Orientation in the Deployment Info in the settings is not set (no checkbox is checked). AppDelegate: the one controller in this case is "SFSafariViewController" //rotation 1 func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { if let rootViewController = self.topViewControllerWithRootViewController(rootViewController: window?.rootViewController) { print(rootViewController) if (rootViewController is SFSafariViewController) { // Unlock landscape view orientations for this view controller print("unlock") return .allButUpsideDown; } } //Only allow portrait (standard behaviour) return .portrait; } 		 		 //rotation 2 private func topViewControllerWithRootViewController(rootViewController: UIViewController!) -> UIViewController? { if (rootViewController == nil) { return nil } if (rootViewController.isKind(of: UITabBarController.self)) { return topViewControllerWithRootViewController(rootViewController: (rootViewController as! UITabBarController).selectedViewController)} else if (rootViewController.isKind(of: UINavigationController.self)) { return topViewControllerWithRootViewController(rootViewController: (rootViewController as! UINavigationController).visibleViewController) } else if (rootViewController.presentedViewController != nil) { return topViewControllerWithRootViewController(rootViewController: rootViewController.presentedViewController) } return rootViewController } 3. Programmatically created SFSafariViewController in the ViewController: import SafariServices let url = URL(string : file_url)! let config = SFSafariViewController.Configuration() config.entersReaderIfAvailable = true config.barCollapsingEnabled = false let vc = SFSafariViewController(url: url, configuration: config) present(vc, animated: true)
Sep ’20