Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a now playing bar like in media player apps in iOS with XCode?

I am making a media player app. I have UITableViewControllers that are embedded in Navigation Controller. I would like to somehow make a view that would overlay potentially multiple (2?) of these tableviewcontrollers (one that shows the user's playlists, and the next would show the tracks in the playlist), but only at the bottom, like a now playing bar in (e.g.) Spotify's iOS app (as in the left bottom side of this

enter image description here

or as in this

enter image description here

I have tried to drag a Container View into my Navigation controller (in which my TableViewCell is embedded), but it won't let me drop it there.

It looks like I can drag the Container View into my TableView, but then how would it remain there when i navigate between tableviews?

Trying to follow @Rintaro's suggestion, but I'm a little new to XCode. How did you do this? So I made a single view application, i added a container view to the first VC, it's imm drawing it somewhere else in the storyboard, but i can't figure out how to tell that view that it's a navigation controller. also, as soon as i add a second container to the first VC and tried to size it, the first container disappears! It is still listed in the hierarchy on the left, and still has an arrow pointing out of it, but the view controller that was added and was being pointed to is also invisible?!

enter image description here

enter image description here

UPDATE: This works very well, but it has a problem with orientation changes. how can i make this work in both orientations? (I hypothesize that it currently positions the "nowplaying view" off screen when the orientation changes).

like image 471
Michael Avatar asked Nov 05 '14 13:11

Michael


2 Answers

Basically, view hierarchy like that is constructed like this:

screenshot

Using two "Container View" in initial view controller, one for Navigation Controller, one for "Now Playing Bar" view controller.

ADDED:

"Main Container View Controller" would be your own UIViewController subclass. It will have responsibility to show/hide "Now Playing Bar".


Workaround for Interface Builder strange behaviors.

You can set Auto Layout constraints like following. Maybe you might want to select the view from the left menu.

Note that, you should uncheck Constrain to margins check box.

Container View for Navigation Controller:

screenshot

Container View for Now Playing Bar Controller:

screenshot

And then, Update Frames from the menu:

screenshot

like image 112
rintaro Avatar answered Oct 20 '22 04:10

rintaro


If you are manually placing any buttons with absolute coordinates, make sure that you update the coordinates of them when the rotation is changed.

like image 44
Alex Kallam Avatar answered Oct 20 '22 06:10

Alex Kallam