Xcode segues for different devices - xcode

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
}

Related

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

Use present as popover in a universal storyboard

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

Showing views in interface builder outside viewcontroller hierarchy in xcode5

I often make use of views in interface builder that live outside of the viewcontroller hierarchy (see screen grab below for simple example).
Before upgrading to Xcode5 I could get this view to appear on the storyboard by writing an IBAction outlet and dragging a connection from the code to the view in the storyboard.
If you paused over the button for a moment it would flash and then open up as a view on the storyboard that is then a lot easier to work with.
Since upgrading this function no longer seems available. Has anyone found out how to get these views to appear on the storyboard?
Edit:
Using the temporary viewcontroller as described in this answer seems one approach, although fiddly since you need to move the UIView stack between viewcontrollers each time you want to edit the layout. Using a separate XIB is starting to seem like the sanest approach.
https://stackoverflow.com/a/13713385/1060154
Finally, we get this back in Xcode 7.
Hallelu!

iPad SplitView as subview

I'm dealing with an iPad project that manages a custom menu and a subview with different stuff on in it, now i want to try to put on this subview a splitview. Is it possible? How can I do it? How can I build my splitview without any template?
The Apple human interface guidelines forbid this and say that the UISplitViewController must be installed as the Root View Controller so it would be best to redesign your app with this in mind since they will not approve it when submitted for review otherwise.
Whilst this is an old question it's still worth adding that Apple seem to have relaxed their rules. I have had a couple of apps approved that have a SplitView inside a TabBar.

Resources