6

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

Community
  • 1
  • 1
Hairy
  • 393
  • 1
  • 10
  • I've never used Apple's Podcast app, so I'm not quite sure what you're asking, but does this help? http://stackoverflow.com/a/33179604/341994 – matt Dec 27 '16 at 17:29
  • I could just rebuild the controls with every segue but I wanted to keep them from being rebuilt if it is possible. – Hairy Dec 27 '16 at 17:55
  • 1
    FYI if you add an 'l' (L not I) at the end of https://i.stack.imgur.com/s1yuZ.png ie make it https://i.stack.imgur.com/s1yuZl.png then the image would be smaller a bit and perhaps better :D – mfaani Dec 27 '16 at 21:36
  • Awesome! had no idea. – Hairy Dec 29 '16 at 00:29
  • Any ideas on how to achieve dragging up this mini player to expand to full screen like in the mentioned podcast app? – vikzilla Jan 16 '18 at 01:56

2 Answers2

9

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

vikingosegundo
  • 52,040
  • 14
  • 137
  • 178
2

I think you can do it adding it on top of application window(which is UIWindow, subclass of UIView)

UIView *myView = /* <- Your custom view */;
UIWindow *currentWindow = [UIApplication sharedApplication].keyWindow;
[currentWindow addSubview:myView];

Took the code from https://stackoverflow.com/a/21850538/1947419

Or you can add to UITabBarController.view directly since it's UIView spanning entire screen.

You need to make custom view for it though.

Community
  • 1
  • 1
christian
  • 445
  • 1
  • 3
  • 12