What is the SwiftUI sheet view equivalent in UIKit? - swiftui

SwiftUI can easily present a sheet view on top of the existing review when a condition is met (see screen record below). What is the sheet component equivalent in UIKit?
Tried to Google a result and it looks like there is a sheet related view called UIActionSheet, but that does not seem like the right UI control.
REFERENCE
Example of how to achieve the same behavior with UIKit.
iOS 14 navigation bar title is not displayed in UINavigationController created programmatically

This is just another UIViewController presented modally with a Done UIBarButtonItem on the right side.

Related

SwiftUI present sheet in a TabItem of TabView using presentationDetents

I am trying to create the same experience where a sheet is presented in one of the tab items of a TabView - not covering the tabs.
I am using .presentationDetents() and SwiftUI4.0 for that.
See example of Apple's own app doing that
The sheet is covering the child view inside TabView.
However, instead in my own code I am getting
this - the tabs of the parent view are covered by the modal sheet
The link https://developer.apple.com/forums/thread/711702 suggests that it is not possible to achieve the same behaviour you see in Apple's Maps and Find My apps with the current SwiftUI API.

How to call a function on original view when modal view is dismissed

I have a SwiftUI puzzle game. I store played puzzles and show in the history view. History view is displayed as a sheet when a button is tapped. In the history view, I want to have a button ("Replay puzzle") which should 1) dismiss the history view, and 2) run a function in the main view so that a game from history view can be replayed.
Seems simple but I could not figure out how to call a function in the main view to update the current game. Any pointers would be appreciated.
Use onDismiss parameter of .sheet, like in https://stackoverflow.com/a/63673342/12299030

How to expose standard back button in view controller navigation?

I need users to be able to navigate a data hierarchy (master level, detail level) and to create new master and detail objects accordingly. Both master and detail use arrays for their model and TableViews for presentation
The navigation flow for this uses 2 navigation and table controllers like below. The + of the master and detail TableViews create new objects, the forstTableCell navigates to the second TableView using a segue:
While the screenshot shows "Done" right now even when removing that ButtonItem the slot remains empty.
I would like to show the standard back button instead: "< Middlewares" in this case. In the tests I've only been able to get the back button when navigating to a normal ViewController, but not to another NavigationController. Is it possible to have it between Navigation Controllers, too?
Simply remove the second navigation controller. If you use a push segue, your second view controller will still have the navigation bar. As long as you don't use a modal segue all view controllers that are pushed will have a navigation bar.
So your storyboard will look like this:
You will then automatically have a back button. If you want to change the text of it, go to your navigation item of your first view controller and change the back title accordingly as shown in this screenshot
You certainly want to have a title in your second view controller (something like "Add [whatever you want to add]". So simply drag & drop a UINavigationItem on your second view controller then you can also add UIBarButton items in your Interface builder
Controlling the look/feel of the Navigation Bar Buttons
You can achieve the behavior you want by opening the Document Outline and find the existing Done button. If you have a UIBarButtonItem type, you can simply change the type to Custom in the Inspector. Next add a regular button within the UIBarButtonItem (just bring the Navigation bar for the target controller into the zoomed in view of the storyboard/xib). This will allow you to drag a button onto the navigation bar.
Once you have a standard button you can add an image with the back arrow. Then add supporting code to use the pop behavior on the Navigation bar. Since you can have only one root navigation controller, you may want to remove the second UINavigationController and add a UINavigationItem from the objects library and then subsequently add the buttons, titles of your choice. This configuration will allow you to leverage all of the push and pop methods available, while retaining full control of the look/feel/behavior of the navigation stack.
More on customizing the look/feel/behavior of the UINavigation Stack can be found at: Navigation API Docs

UITabBarController containing UISplitViewController doesn't handle rotation on iPad correctly

I’m experiencing unusual behavior on an iPad in iOS 6.1.2 when using a UITabBarController with a UISplitViewController (which has a UITableViewController for the master view controller). If I have multiple tabs, of which at least one tab contains a split view controller, and I am in landscape mode while viewing the tab that contains the split view controller, then I switch to another tab, then move to portrait mode, then press the tab that contains the split view controller, what happens next is that the master view controller (a table view controller) will display the table view over top of the detail view, when it is clearly not supposed to be there. This behavior happens only the first time the app is loaded, but is consistent behavior.
This scenario is easy to recreate by simply creating a project that is a split view application that uses an iPad device and Core Data (didn’t try it without using Core Data). After the project is created, use the storyboard and add a tab bar controller and make it the initial view controller, then add a view controller seque from the tab bar controller to the split view controller. After that, only one change is necessary in code which is to change the one line in application:didfinishLaunchingWithOptions in the AppDelegate.m:
Change the following template code:
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
To:
UITabBarController *tbc = (UITabBarController *)self.window.rootViewController;
UISplitViewController *splitViewController = [tbc.viewControllers lastObject];
Perhaps I’m breaking some iOS rules, and trying to do something I’m not supposed to? All I want to do is to be able to tab between a few different split view controllers. Suggestions?
Take a look at this Git.
https://github.com/nalyd88/DCToolkit/tree/master/DCToolkit/DCToolkit
From what I understand the problem stems from the split view controller not updating it's orientation when it's not visible.
Here a subclassed tab view controller and split view controller are used which pass the message along.
Thanks to Dylan at http://objectiveseesharp.wordpress.com/ for this solution! I just found it.

TabBar inside detail view of SplitViewController.

I am trying to embed a Tabbar in the Detail side of a Split View Controller. The way I have done is that in the Storyboard I have the TabBarController as the DetailViewController and from there I have a couple of Navigation Controllers hooked to views ( separate tabs which are of type DetailViewController).
The problem I am facing is that out of two tabs which I have added, only one tab shows the button for showing the Master view in the Portrait mode.
I am new to iOS development, and would deeply appreciate any help towards solving this.
Thank you for your time.
From the documentation for the UITabBarController: "When deploying a tab bar interface, you must install this view as the root of your window. Unlike other view controllers, a tab bar interface should never be installed as a child of another view controller."
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITabBarController_Class/Reference/Reference.html