How to present a View Controller without hiding the tabBar - ios

I have a UITabBarController with five view controllers in it. In one view controller, a button can be pressed to present a new ViewController, but the tabbar is covered. How can I present the controller and keep the tabbar visible?

When you present something, it will cover entire screen.
The controller from where you want to present a new controller, make it as navigation controller rather keeping it as simple controller.
So, you can push the new controller on it rather than you present.

[<presentingViewControllerInstance> setModalPresentationStyle:UIModalPresentationOverCurrentContext];
Use currentContext as presentation style for the presenting view controller before presenting. No need to create a navigation controller and push.

Related

Navigation Tab Bar Controller to UIView Controller?

I am using tab bar controller and i want to push uiview controller over tab bar controller. but i don't know how we push UIView controller over Tab Bar Controller. Thanks
You need to embed a navigation controller in your tab bar controller screen where you want the push set up to work
If I'm reading your question right, you want to push a view controller over another view controller which is currently displaying tabs.
In this case, I believe you would need a UINavigationController as your root view controller. Inside this navigation controller, you would initially push a UITabController with it's associated view controllers per tab. When it's time to push another view controller over the tab controller, create an instance of the view controller to push and use the following code:
[self.navigationController pushViewController:newViewController animated:YES];
This will push the new view controller over the existing TabController that is currently being displayed.
The question is little vague Hence I will add the two way to push to another view controller we use in common.
From navigation controller : You just need to create an UIButton in the navigation controller and then control + drag the button to another view controller to create a push feature to another screen in storyboard.
From Tab view Controller : Similarly, control key + drag the tab bar item in the tab bar controller to another UIView controller in the story board. Then chose 'show' option to create a push to another UIview controller screen.
Hope this helps.
Tab Bar controller is different and Navigation Bar controller is different.
And as Pittmaster says, your navigation view controller should be root view controller.

Segue-ing to Embedded view controller

I have have a view controller that is embedded in a UINavigationController and I want to segue to another view controller that is also embedded in a different UINavigationController. If I try to use a push segue, I get an error saying that I can't push a UINavigationController. However, I don't think using a modal segue is appropriate. How should I go about this?
How should I go about this?
You should use a single navigation controller.
the problem is that I want different bar button items for each view controller and they won't change
Each view controller can set up the bar buttons however it likes. Take a look at UINavigationItem. Each view controller has a navigation item, and the navigation item has various properties such as leftBarButtonItems and rightBarButtonItems that you can use to set the buttons.

What are limitations of presentViewController over UINavigationController

I am confused about "In which situations we have to use presentViewController and UINavigationController".
I had read so many documents, but I haven't found accurate explanation. We can always use UInavigationController then what is the use of presentViewController ?
Thanks.
UINavigationController maintains the stack of the controllers that are being viewed. So once you push through 1->2->3 view controllers then you can pop in 3->2->1 manner. Unless you don't change the stack this kind of flow is maintained by UINavigationController. Now lets say you want to show 4th view controller without disturbing the above flow. Then you can use presentViewController.
This is the simplest and basic is for using navigation controller and presentViewController
You can't push a navigation controller into other navigation controller.
You can present a navigation controller above other navigation controller.
If you push a view controller into the navigation controller, view controller's view cover only area inside navigation controller.
If you present a view controller, view controller's view cover the window hierarchy (user can't interact with other parts of the application).
You can don't use UINavigationController to present some UIViewController. You should care about "close" button to let user to close presented UIViewController
I've create test project to illustrate my answer https://github.com/K-Be/PresentTest

iOS View controller's view alpha

Can I reveal the underlying view (or the view at the back of a view controller), by making a view controller's view transparent? I tried and it just fades to black and doesn't reveal anything behind it.
Reason?
EDIT:
Okay, this question needs more context.
I have a view controller. Now I am going to present another view controller(simple presentation of view controller, modally). After the new view controller has been presented, I am making its view transparent with alpha=0. Why does it not reveal the underlying view controller's view?
Will using the iOS 7 Transition API help?
If you present your view controller modally (using presentViewController:animated:completion:) then the presenting view controller's view will be removed removed from the window, therefore you cannot see through your presented view controller to the presenting view controller. You might want to use child view controller: https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html
Alternatively, you can present your view controller inside a new UIWindow.
You cannot see the original view controller because you use -presentViewController:animated:completion: which will hide the presenting view controller after the animation finished.
You can set the modalPresentationStyle to one of UIModalPresentationOverCurrentContext, UIModalPresentationOverFullScreen and UIModalPresentationCustom before you called 'presentViewController:animated:completion' so that the underlying presenting view controller will not be hidden.
If you would like to have the same background image showing below all UIViewController you can add a UIImageView to the [UIApplication sharedApplication].window in the applicationdidfinishlaunching method

What is the difference between Modal and Push segue in Storyboards?

Can someone explain to me what is the exact difference between modal and push segue?
I know that when we use push the segue gets added to a stack, so when we keep using push it keeps occupying memory?
Can someone please show me how these two are implemented?
Modal segues can be created by simply ctrl-click and dragging to destination but when I do that with the push my app crashes.
I am pushing from a button to a UINavigationController that has a UIViewController.
A push Segue is adding another VC to the navigation stack. This assumes that VC that originates the push is part of the same navigation controller that the VC that is being added to the stack belongs to. Memory management is not an issue with navigation controllers and a deep stack. As long as you are taking care of objects you might be passing from one VC to another, the runtime will take care of the navigation stack. See the image for a visual indication:
A modal Segue is just one VC presenting another VC modally. The VCs don't have to be part of a navigation controller and the VC being presented modally is generally considered to be a "child" of the presenting (parent) VC. The modally presented VC is usually sans any navigation bars or tab bars. The presenting VC is also responsible for dismissing the modal VC it created and presented.
Swift 3.0 and XCode 8.2.1 update
1. Push Segue
Push segue has been renamed as Show segue. To create push segue, the parent view controller needs to be embedded in navigation controller. The navigation controller provides navigation bar. Once you connect two view controller with push segue, the child view controller will automatically has navigation bar on top. The child view controller will be added on top of the navigation stack.
Push segue also provides default features. The child view controller will have a back button that gets you back to the parent view controller. You can also swipe right to pop the child view controller. The animation for push segue is like sliding pages horizontally.
While you are allowed to make a push segue from a view controller that is not in a navigation controller, you will lose all the features like navigation bar, animation, gesture etc when you do so. In this case, you should embed your parent view controller inside navigation view controller first and then make push segue to child view controllers.
2. Modal Segue
A modal segue (i.e. present modally), on the other hand, is presenting over the current view controller. The child view controller will not inherit navigation view controller so the navigation bar will be lost if you present modal segue from a view controller with navigation view controller. You have to embed the child view controller in navigation controller again and start a brand new navigation stack if you want it back. If you want to get back to parent view controller, you have to implement this by yourself and call dismiss from code.
Animation for modal segue is that the child view controller will comes up from the bottom of the page. The navigation view controller is also gone in this demo
The push view must be built in a navigationController.
Click on your master view, then in the menu bar choose:
EDITOR->embed in->navigationController
This is pushing controls using custom push and segue methods for storyboard
And Modal is way to navigate through views without using Storyboards.

Resources