Use present as popover in a universal storyboard - xcode

Apple recommends to use a single storyboard for universal apps through size classes.
Now I am trying to adapt the UI depending on the device, which has worked quiet well so far. The only problem I'm facing is how to assign the specific segues.
For instance the settings, which in my App consist of only two tableview cells, should be made visible via a "present as a popover" on the iPad and a regular "show (e.g. Push)" segue on the iPhone.
Is there any way to define it just like that using storyboards or do I need to write supporting code?
Nick

In WWDC session Apple engineer used "Present as popover" segue.
This one shows view modally on iPhone and popover on iPad. Though, you'll have to write some code to show Back button on iPhone.
If you need to have popover and push segues, I'd do that in code this way:
Make 2 segues 'Present as popover' and 'Show'
Set up segue identifiers
In code identify whether app running on iPhone or iPad
Launch correct segue

Related

How to convert manual view controller to storyboard as a launch screen

New iOS requirements need Apps for iPhone or iPad must be built with the iOS 13 SDK or later and use an Xcode storyboard to provide the app’s launch screen.
But my project is very old and has never used Storyboards. All UI elements are created dynamically using ViewControllers.
I managed to create a storyboard file and set it as a launcher but it has no scenes and I do not know how to proceed. I would like to:
Create a scene where I place only the original launch image inside (hoping that apple still accepts this branding)
If it is possible to just connect my main ViewController with the scene (if that works with dynamical ViewControllers)
If nothing helps than I would need to create a simple scene which has just a bottom bar like my ViewController
I had this exact issue, here's what I did:
Create LaunchScreen.storyboard and set to use it as launch screen
Using the + button in the top-right (this was not an obvious step), add a View Controller into the storyboard
Untick "Use Safe Area Layout Guides" on the right panel if you're getting that error
Tick "Is Initial View Controller"
Then clean and run, for me it just worked. I did have trouble seeing it update though, as discussed here: Launch Screen storyboard not displaying image

iOS 13 Presenting Modal half screen for iOS, popover for iPadOS

What I'm looking to achieve is the exact same behavior as share view of iOS 13. I want to present my custom picker view as popover on iPad, and as semi modal on iPhone. I'm currently using "present as popover" on storyboard, which I get the default behavior that auto switches between popover and modal for free. I guess I need to switch to custom controller, but I'm lost on how to achieve this.

Xcode segues for different devices

I make an application for iPhone and iPad. I want that different segues for different devices. An example for iPhone segue is "Show" and iPad is "Show Detail". I tried it in the Storyboard but it doesn't helped me. How can I do it?
Just create the segues with some identifier and based on the device perform some segue. I think there is no built in way to do it from storyboard.
While there is no built in way to do this, there are some creative workarounds. The answer I'm giving you will work, but it is primitive. You are correct that you cannot create two segues from the same table view cell, so you need to make two table view cell files, with the one inheriting from the other. Each file can contain a separate segue, and you can call that segue depending on which device is running at that time. You can check to see which device is running in AppDelegate.
Pseudo code would look something like this:
if device is iphone {
use this segue
} else if device is ipad {
use this other segue
}

How to incorporate a UISearchController into new (iOS8) UISplitviewController

I try to build a simple app based on the UISplitViewController template from Xcode 6 for universal apps (with Storyboard and CoreData/NSFetchedResultsController). This app should also provide a search bar for the MasterViewController. Unfortunately, Xcode 6 provides no InterfaceBuilder element for the UISearchBar/UISearchController combo (only the depreciated UISearchBar/UISearchDisplayController).
In the iOS Developer library, Apple provides the "Table Search with UISearchController" example, but this is not based on the UISplitViewController and supports only iPhone.
My problem is, that I'm not able to show the detail view on the correct ViewController under all circumstances. I tried to transfer the approach from the Apple example project to the UISplitViewController template. In this, one is encouraged to show the search results in a separate UITableViewController subclass (ResultsTableViewController) and use this as the searchResultsController of the UISearchController. I was not able to create a scene in InterfaceBuilder for this setup so I had to add these manually in code.
The problems begin when I click on a table cell of the ResultsTableViewController. This vc is not part of the scene in InterfaceBuilde and I don't know how to add it to the SplitViewController setting correctly. The biggest problem is the weird behavoir of the iPhone 6 Plus and the UISplitViewController. In portrait mode it behaves like an iPhone and doesn't seem to have a SplitViewController and only uses a NavigationController to which I push my DetailViewController. In landscape mode it behaves like an iPad with SplitViewController were I have to get the second ViewController of the SplitViewController childControllers and push the DetailViewController on this one.
Now it happens, when I start in portrait mode and switch to landscape mode that the DetailViewController is all gone, showing gray space where the DetailVC should be. It seems, when going to portrait mode, the DetailViewController gets kicked from the SplitViewController (or the SplitViewController gets kicked at all in favor for the iPhones NavigationController setup). When switching back to landscape the SplitViewController is initialized again but without proper initialization of the DetailViewController.
Is there any template or suggestion on how to correctly implement search capabilities on a universal UISplitViewController?
Cheers
Björn

Using a textView and ScrollView in the same ViewController does not work? Swift

I am having a very strange problem.
I have a tableView, which when the cell is clicked it segues to the next VC, sending the data from that cell with it via prepareForSegue function. From the next VC I then segue from there to another VC (again passing the data needed via prepareForSegue). The final VC is a chat style VC, so it contains a scrollView and a textView, the three VCs look like so:
In the chatViewController I have set up a Parse backend so it queries the data and then places inside the scrollView like so:
The problem I am having is that the keyboard does not pop open. I know the code is CORRECT! As it pops open when I make the chatViewController the initial VC. it just doesn't work when it is segued to from multiple VC.
Does anybody have any ideas on this or ever had any problems with segueing into a scrollViewController. I've tried everything I can think off.
Thanks in advance.
If you're on ios simulator, the software keyboard may be turned off. For actual emulation you may try a ios phone instead of simulator.
If you wanna appear the soft-keypad in simulator try following
solution
iOS Simulator -> Hardware -> Keyboard
Uncheck "Connect Hardware Keyboard"
Mine was checked because I was using my mac keyboard, but if you make sure it is unchecked the iPhone keyboard will always come up.
solution is actually copied from here

Resources