Shrink view controller while presenting another - ios

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

Related

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

How to always show a viewcontroller even when navigating screens in 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

Creating a custom navigation controller that controls two views

So I am creating an app for iPhone and iPad. I am currently working on the iPhone version. I need to implement a custom navigation controller that controls only both view controllers that are on the screen. It's better to demonstrate the situation with a few pictures.
So what I want to do is have a navigation controller that can control both of my view controllers and I can push a new view controller on the bottom or on the top with the other staying as it is. I have no problem with doing the basic code like pushing a new view controller, animating the transition etc. What I am asking is more about the "correct way" of making this. Also how can I link the IBOutlets in navigation controller to the custom view controllers in Xcode, if I try to drag it to my view controller, it won't let me, I think it's because they're in different groups(see picture 2). Is there any way to do this?

Get a reference to the currently visible view controller

I have a UIAlertView. When the user taps a button in the alert view I want to show a new UIViewController.
In order to achieve this I need to know which view controller is currently visible on screen because that particular view controller is the right one to present the new view controller.
The problem is that I have a complex hierarchy of view controllers in my app including a UINavigationController and a UITabBarController (among others). So I cannot simply use self.visibleViewController to get the currently visible view controller.
I have found a possible solution on Stackoverflow but I would like to find a neater solution without having to dig through the whole view controller stack.
UINavigationController has a property called topViewController.
Maybe it helps you.

iOS UINavigation Controller basics and custom back button

I make my first "serious" iOS app, and have some troubles with the whole UINavigation concept, but all in order. I look answers for my questions but don't find what I want, so here it is.
I want to make menu to a game, it would be look like so:
1) It's a RootViewController and it contain some buttons: new game, options, about.
2) I think it will be another view controller (It must appear when we touch new game button, and we see a menu when we choose game difficulty) the buttons is: easy, medium, hard
3) The game view controller (I think that this VC won't be the part of UINavigationController).
I have some concepts that I want to embody in this menu.
Here is it: I don't want to use UINavigationController Navigation bar, I won't use standard slide animation for UINavCon, I want to make my buttons "move to transparency" and come back with another menu from paragraph 2 mentioned above, it's not necessarily to change background or something else except menu items.
I want to use custom back button, and want to add it to the position I want and not to Navigation Bar.
I have some ideas about animation of menu items.
I don't know this:
It is better to use UINavigationController for my purposes or it's better to use normal ViewController?
If I make a UINavigationController can I see it's "child VCs (I mean not a root VC)" in my storyboard or it will be programmatically created thing and I must make it UI in code? If i must do this programmatically, could I make a segue from UINavigationController from storyboard, or I must do this from code too?
Could I make a UIButton, for example, and assign it functions from a normal UINavigationController back button from Navigation Bar?
Some questions might be dumb, but hope you won't judge me hard.
Okay, I'll do my best:
For custom animations, see
Yes, you make a custom segue class with the animation. try: joris.kluivers.nl/blog/2013/01/15/… and developer.apple.com/library/ios/#featuredarticles/… and cmumobileapps.com/2011/11/04/a-short-tutorial-on-custom-segues
Yes, i think a view controller is your best bet. But by the way, even if you use a navigation controller, you still use normal view controllers. A UINavigationController holds different UIViews, which go forward and backward on the navigation stack. Also, you will need to look up what you need to do to hide the navigation controller.
You can see the child view controllers in a storyboard if you create them their, but not if they are created programmatically, unless you just have the view in their.
[self.navigationController popViewControllerAnimated:YES] will "press the back button" programmatically, so just link the custom back button to a method that calls this.
If that doesn't cover all of your questions, just comment and I'll answer any more :)

Resources