Post

Replies

Boosts

Views

Activity

Apple does not support UISplitViewController.DisplayMode.PrimaryOnly as splitViewController.preferredDisplayMode
How can enable the masterViewController as UISplitViewController.preferredDisplayMode (UISplitViewController.DisplayMode.PrimaryOnly) on higher-end iPhone devices (such as iPhone 14 Plus) in landscape mode? I am utilizing a splitView with the style .doubleColumn. My objective is to have the splitView present the MasterView as the initial screen and the Detailed view as the subsequent screen in landscape mode, resembling the default iPhone portrait mode, specifically on higher-end iPhone devices (such as iPhone 14 Plus and iPhone Pro Max). If launched on an iPad, it should be displayed as 'side by side' ('oneBesideSecondary'). How can we display the MasterViewController using splitViewController.preferredDisplayMode, specifically setting it to UISplitViewController.DisplayMode.PrimaryOnly when rotated to landscape mode on iPhone higher end devices? However, it's important to note that Apple does not support UISplitViewController.DisplayMode.PrimaryOnly. class ViewController: UIViewController , UISplitViewControllerDelegate { var splitVC = UISplitViewController(style: .doubleColumn) var delegateProtocol : TableSelectionDelegate? var ListView : ListViewController! override func viewDidLoad() { super.viewDidLoad() splitVC.delegate = self splitVC.presentsWithGesture = true splitVC.preferredSplitBehavior = .tile ListView = ListViewController() } override func viewWillAppear(_ animated: Bool) { var primaryVC : ListViewController = UIStoryboard(name: "Main", bundle:nil).instantiateViewController(withIdentifier: "ListViewController") as! ListViewController var secondVC : SecondViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "SecondViewController") as! SecondViewController primaryVC.delegate = self secondVC.view.backgroundColor = UIColor.placeholderText if UIDevice.current.userInterfaceIdiom == .pad { splitVC.setViewController(primaryVC, for: .primary) splitVC.setViewController(secondVC, for: .secondary) splitVC.preferredDisplayMode = UISplitViewController.DisplayMode.oneBesideSecondary } else { splitVC.setViewController(secondVC, for: .primary) splitVC.setViewController(primaryVC, for: .secondary) splitVC.preferredDisplayMode = UISplitViewController.DisplayMode.secondaryOnly // hide back btn to primary list let controllers = splitVC.viewControllers primaryVC = (controllers[controllers.count-1] as! UINavigationController).topViewController as! ListViewController primaryVC.navigationItem.leftBarButtonItem = splitVC.displayModeButtonItem primaryVC.navigationItem.leftItemsSupplementBackButton = false } addChild(splitVC) splitVC.view.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height) self.view.addSubview(splitVC.view) splitVC.didMove(toParent: self) } func splitViewController(_ svc: UISplitViewController, willChangeTo displayMode: UISplitViewController.DisplayMode) { if UIDevice.current.userInterfaceIdiom == .phone { svc.presentsWithGesture = displayMode != .secondaryOnly } } } extension ViewController : TableSelectionDelegate { func selectedRow(row: Int, viewController: UIViewController) { splitVC.showDetailViewController(viewController, sender: self) } } I attempted the code above by swapping the PrimaryVC with .secondary and the SecondaryVC with .primary in the splitView for the iPhone device type. As a result, I achieved the desired UI. splitVC.setViewController(secondVC, for: .primary) splitVC.setViewController(primaryVC, for: .secondary) splitVC.preferredDisplayMode = UISplitViewController.DisplayMode.secondaryOnly. However, I'm uncertain whether this approach was correct or incorrect. What would be the best approach to achieve my desired UI? Desired UI :
1
0
451
Dec ’23
Apple does not support UISplitViewController.DisplayMode.PrimaryOnly as splitViewController.preferredDisplayMode
How can enable the masterViewController as UISplitViewController.preferredDisplayMode (UISplitViewController.DisplayMode.PrimaryOnly) on higher-end iPhone devices (such as iPhone 14 Plus) in landscape mode? I am utilizing a splitView with the style .doubleColumn. My objective is to have the splitView present the MasterView as the initial screen and the Detailed view as the subsequent screen in landscape mode, resembling the default iPhone portrait mode, specifically on higher-end iPhone devices (such as iPhone 14 Plus and iPhone Pro Max). If launched on an iPad, it should be displayed as 'side by side' ('oneBesideSecondary'). How can we display the MasterViewController using splitViewController.preferredDisplayMode, specifically setting it to UISplitViewController.DisplayMode.PrimaryOnly when rotated to landscape mode on iPhone higher end devices? However, it's important to note that Apple does not support UISplitViewController.DisplayMode.PrimaryOnly. class ViewController: UIViewController , UISplitViewControllerDelegate { var splitVC = UISplitViewController(style: .doubleColumn) var delegateProtocol : TableSelectionDelegate? var ListView : ListViewController! override func viewDidLoad() { super.viewDidLoad() splitVC.delegate = self splitVC.presentsWithGesture = true splitVC.preferredSplitBehavior = .tile ListView = ListViewController() } override func viewWillAppear(_ animated: Bool) { var primaryVC : ListViewController = UIStoryboard(name: "Main", bundle:nil).instantiateViewController(withIdentifier: "ListViewController") as! ListViewController var secondVC : SecondViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "SecondViewController") as! SecondViewController primaryVC.delegate = self secondVC.view.backgroundColor = UIColor.placeholderText if UIDevice.current.userInterfaceIdiom == .pad { splitVC.setViewController(primaryVC, for: .primary) splitVC.setViewController(secondVC, for: .secondary) splitVC.preferredDisplayMode = UISplitViewController.DisplayMode.oneBesideSecondary } else { splitVC.setViewController(secondVC, for: .primary) splitVC.setViewController(primaryVC, for: .secondary) splitVC.preferredDisplayMode = UISplitViewController.DisplayMode.secondaryOnly // hide back btn to primary list let controllers = splitVC.viewControllers primaryVC = (controllers[controllers.count-1] as! UINavigationController).topViewController as! ListViewController primaryVC.navigationItem.leftBarButtonItem = splitVC.displayModeButtonItem primaryVC.navigationItem.leftItemsSupplementBackButton = false } addChild(splitVC) splitVC.view.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height) self.view.addSubview(splitVC.view) splitVC.didMove(toParent: self) } func splitViewController(_ svc: UISplitViewController, willChangeTo displayMode: UISplitViewController.DisplayMode) { if UIDevice.current.userInterfaceIdiom == .phone { svc.presentsWithGesture = displayMode != .secondaryOnly } } } extension ViewController : TableSelectionDelegate { func selectedRow(row: Int, viewController: UIViewController) { splitVC.showDetailViewController(viewController, sender: self) } } I attempted the code above by swapping the PrimaryVC with .secondary and the SecondaryVC with .primary in the splitView for the iPhone device type. As a result, I achieved the desired UI. splitVC.setViewController(secondVC, for: .primary) splitVC.setViewController(primaryVC, for: .secondary) splitVC.preferredDisplayMode = UISplitViewController.DisplayMode.secondaryOnly. However, I'm uncertain whether this approach was correct or incorrect. What would be the best approach to achieve my desired UI? Desired UI :
Replies
1
Boosts
0
Views
451
Activity
Dec ’23
iPad safe area in Apple Design Resources – iOS 17 and iPadOS 17
Hi All, I could n't understand iPad safe area guide lines based on Apple Design Resources , could anyone please describe it .
Replies
1
Boosts
1
Views
852
Activity
Nov ’23
KeyboardType(.NumericPad) not supporting For WatchOS in SwiftUI
TextField("BG Value", text: $text).keyboardType(.numberPad) when ever i tried to show numberpad as TextField Input i am getting error Error as below : Cannot infer contextual base in reference to member 'numberPad' Value of type 'TextField' has no member 'keyboardType' Any suggest me on this issue
Replies
1
Boosts
0
Views
1.6k
Activity
Jul ’23