How to always show a viewcontroller even when navigating screens in iOS? - ios

I have this music player view controller that can be minimized. Thanks to LNPopupController[https://github.com/LeoNatan/LNPopupController].
Everything is working fine, but I have no idea how to make this music player view controller stays on top even when the user navigates to the other screens (even when the main navigation controller pushes another view controller). The app doesn't use tab bar controller by the way.
So, is there a way to implement this kind of idea? Again, sticking the minimized view controller on top of every screens of the app?

Developer of the framework here.
If you present the popup bar from a navigation controller, it will appear for all pushed controllers. Likewise for a tab bar controller.
If you need to have it for all controllers, it's not easily possible. One way is the have your entire application scene appear as a child controller of a view controller, and have that controller present the popup bar. This is a difficult way to make it work, and not recommended. It has many issues.
The popup controller is not meant to appear on the screen all the time. It is meant to implement a similar functionality as Apple's.

add the minimized view controller on keyWindown which your minimized view controller always on top ,I didnot Know whether can help you,the code demo gif as is show,If anyone need Demo,give me Email:59620one463qq.com(replace one to 1) to get demo

Related

Youtube-like video control bar in the bottom

In the youtube app there's a possibility to collapse video into a small preview window with a playback and controls while you navigating in the different parts of the app. By tapping on the window you can always switch to full screen mode again.
I wonder: what't the best approach to implement similar functionality? For now I see few options but I'm not very well aware of the implications of these options.
Note: I have an iPhone tabbar based app.
Create a popover modal view controller, that is presented on top of current navigation stack in a current tab
Create a view and stick it to the bottom of the screen.
Create a view in bounds of a tabbar controller
Create a modal view controller embedded in tabbar controller.
Just from the list I suspect that using a specialized UIView (2) would be the worst possible way to do this. But I don't know about the rest. Any advice would be greatly appreciated.

How to Share a View Across a Navigation Hierarchy with No Animation?

I have a simple Navigation View Hierarchy that has 2 views it goes between. I wanted a customized navigation bar, so I have the default one hidden, and I've implemented a Container View which is shared between the 2 views in the nav hierarchy.
Everything works as I want it to, except when I segue to the lower or higher view the top bar appears slides away and reappears on the new view. I would like it to appear stationary when I push or pop to other views in the hierarchy.
Is there an easy way to do this? Or should I delete my custom shared Container View and try to make this work with the Navigation Bar (which I have currently "hidden")?
I had to do this for a client once. The way we did it was, like you said, make an encompassing view controller that housed a container view. Within this container view, we embedded a UINavigationController and would manually pop and push UIViewControllers to its navigation stack. Of course you want to hide the UINavigationController's nav bar.
It sounds like you sort of implemented this, but instead you just embedded a plain old view controller inside your custom navigation controller, and then segue to another view controller that is also embedded in the custom view controller? Ideally you want one instance of this custom nav controller with an embedded UINavigationController. I believe you will have to do all the view controller transitions programmatically.
Opinion: Personally, I would recommend against doing this. I believe that an app should feel like an extension of the OS it's on. A user should feel it's a part of their phone. Using the native navigation bar also decreases the level of effort a user is required to put forth to understand your app.
I know you're thinking "but it's just a nav bar" but we're talking about the same people that will potentially uninstall an app if it takes longer than 2.5s to load.
I wanted a customized navigation bar, so I have the default one hidden
That's your mistake. The way to get a customized navigation bar in a UINavigationController interface is to initialize it with init(navigationBarClass:toolbarClass:). Now the built-in navigation controller is using your navigation bar! And from there on, all will be well.
https://developer.apple.com/reference/uikit/uinavigationcontroller/1621866-init

Displaying user information on an popover alert view controller

I am working on an app for a Cafe where users can "sign in" to their seats.
Currently I am thinking of a way to present basic user information of seated people. What I am envisioning is to when the table gets tap, a square information box (pardon my primitive language) appears in the middle with the background being blurred out. I am hoping to have something flexible so that i can add tab and such to this so called box.
I have been looking at popover alert controllers and apparently there is limited information on them in regards to the iPhone. Is there a reason why popover view is not used for iPhones as compared to iPads? Moreover, is there a smarter UI to handle this or should i just segue to the next view when tapped.
Basically, popovers are iPad-only because iPhone screens are too small to make them effective. UIAlertController is a similar alternative, though it may not lend itself to what you're trying to accomplish.
Segueing to a new view for the user information is definitely a solid option, or if you want to preserve the feeling of staying on the same view you can animate a custom view over top of your current view, often from the bottom in the style of a keyboard or the settings drawer.
I think you are mixing up two different concepts: Alerts vs View Controllers being displayed modally.
Alerts – as the name suggests – are used to bring something important to the attention of the user. They usually interupt the current flow.
View Controllers presented modally are similar to what you discribe: a new View Controller moves over the current one, and the current one is blacked out to put emphasis to the new one. As you rightly pointed out though, this is hardly used on iPhone: This is because iPhones historically have rather small screens, and scaling down a view controller leaves hardly any room for content.
View Controllers presented as popovers is yet another thing: Here, you show the new view controller in a separate window that originates from a specific point in your UI.
This document might be of interest for you.
You may want to use a Modally presented View Controller. For this, you will create the view you want to pop up in a separate view controller. Then, control-drag in a segue from the parent view to the Modal of type Present Modally. You can even get your blurriness by setting your Modal's background to clear and adding a Visual Effect with Blur to its view.
Now, give the segue an identifier in the right hand pane so you can call it programatically.

Shrink view controller while presenting another

I want to modely present a view controller, and during the animation I want to shrink the presenting view controller. I saw a lot of apps doing this effect, its seams that the entire view controller including the navigation bar is shrieked.
I'm not sure how to approach this, and I will really appreciate any help about how to make this kind of effect.
here is an example from the mail app, you can see that when the compose view controller is presented, the other view controller is shrieked behind him:
If this was for iPad I would tell you to simply use an embed segue, or resize your modal container's superview, but since it is for iPhone that makes things trickier. Apple has said that modal presentation for iPhones is always supposed to be the whole screen, so I doubt they did theirs modally. They either made a custom segue type (I'm not sure how to go about doing that), or they simply are using a view and presenting that on the bottom portion of the screen, with a view inside of it to represent the navigation controller.
You can add a different viewController's view to the current view controller then call parentVC addChildViewController: and use it like that. Just use a toolbar instead of a nav bar and it should work fine.
I was looking to do the same and I found this answer by Brian Sachetta that explains how to accomplish it. The link posted in the answer didn't work for me but I found the sample he is talking about here

iPhone popover controller present view controller fullscreen

I am using a third party popover controller on the iphone and have ran across an issue. The one I'm using is WYPopoverController but have tried using FPPopover and it has the same "issue" since they work in a similar way. Here is the deal:
I have a notifications button in my app which pops up a popover controller which contains the notifications feed. It's like the Facebook app. You can see it on the below image.
Now what I want to do it so present a view controller on top of everything and in full screen. The way that popover controller works is that it ads its view directly to the applications main window and its not nested in the view hierarchy so I get a warning saying presenting view controllers on detached view controllers is discouraged and it does not present full screen as well (I know thats logical). If I present it on the parent view controller (the red one in the background) it gets presented below the popover view.
How to fix this?
I was thinking about using a new UIWindow instance and using a root view controller there. Is this an OK solution or is it a hack? If it's ok then how do I accomplish this? I want the presentation and dismissal to be animated :)
I want it to look like Facebok Paper app when you tap an item in the notifications feed.

Resources