Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a view that stays onscreen when the main view segues?

How do I make a view that does not appear to be reloaded (stays onscreen) every time a view segues? Like the audio controls in Apple's iOS podcast app. See pictures to see audio controls I am referencing.

How do I do it in storyboard?

enter image description here

like image 948
Hairy Avatar asked Dec 27 '16 17:12

Hairy


People also ask

How do you create a show segue?

To create a segue between view controllers in the same storyboard file, Control-click an appropriate element in the first view controller and drag to the target view controller. The starting point of a segue must be a view or object with a defined action, such as a control, bar button item, or gesture recognizer.

What is instantiate view controller?

instantiateViewController(withIdentifier:)Creates the view controller with the specified identifier and initializes it with the data from the storyboard.


1 Answers

What you are referring to is usually called "mini player", you'll find it in many other apps too.

The technique you should use is called "UIViewController Containment", in storyboards it is accessible as "Container View" and "Embed Segues".

A typical storyboard might look like:

  • The root view controller has two Container View added to it's view.
  • The container views have segues to view controllers. In the view
  • controller that relates to the lower one, setup the mini player.
  • The view controller of the upper container embed in a navigation controller and a tab view controller.

screen

This will create the view controller hierarchy.

To implement the player itself create a player class that you instantiate in the app delegate and pass it to a property on the root vc. from there pass it to the mini player view controller and to the upper view controller, that will contain the list of songs/podcast/... to select from. At selection pass hat song to the player class.


I posted an example app at GitHub: https://github.com/vikingosegundo/HearThisMiniplayer

screen

like image 152
vikingosegundo Avatar answered Oct 08 '22 04:10

vikingosegundo