Basically once I dismissed the modal view, my customized UIToolbar no longer clickable.
Here is my design:
a customized UIToolbar at the bottom of the screen
top part of the screen is associated with a container view controller
[note] I added the top two items above into a root view controller and assigned to UIWinow's root view controller. The container view can be changed whenever toolbar items are clicked.
then, each toolbar item associated with a UINavigationController so that it's navigable.
within a UIViewController of a navigation, I present a view modally. The modal view does NOT cover the full screen as a result of the entire design...
after i dismiss the modal view, the UIToolbar items are no longer clickable.
I think the 'bug' is resided in where i presented the modal view, so I also tried to present modal view using root view controller, then there is also other issues...
maybe someone has more insight on this, that will be really appreciated :)
Thanks.
Try releasing the modalViewController as soon as its no longer needed. If you are using ARC, set it to nil. Allocate a new one when a modalView is needed.
Related
I am a bit new to iPhone development and working on learning it on my own.
I have a view controller which contains 2 parts:
Image View - some picture + some text on top of it
Container view
the container view is now segued into a new controller view which I replaced with a collection view. The idea here is for this to hold some picture I can click on to get to another page yet.
So, with all that, I have things working fine. My main view shows the top picture + text and below is all the smaller pictures which are clickable and that take me to another view that is being presented modally.
The final view is a UIView that contains in it a imageView to hold the picture I clicked on the other view. This even works fine.
The issue is that I am trying to add a naviagtion bar on top of the new view which shows up fine in story board and I added a button to close it. But that for some reason does not show up when I run the application.
If I change the presenting mode to Push, I see the navigation bar show up with the back button as well, but my close button does not work there either (code added to dismiss the view correctly).
What am I doing wrong with the modal presentation?
If you want to present a view with a navbar modally, it has to have it own NavigationController.
So too have a NavigationBar in a modal displayed View, drag a UINavigationViewController in front of your ViewController, e.g.:
This is not needed in case of a push segue, as the pushed ViewController is still child of the original UINavigationViewController, wich is owner of the NavigationBar
The NavigationBar is managed by the UINavigationController, wich is on the parent-side.
So if you add Buttons in the Storyboard, you are adding these buttons to the NavigationItem, wich belongs to the ViewController.
Im writing an application which the main view controller is a UIViewController. It has some icons in a grid and I want to dismiss (sliding down) this grid when one of the icons is clicked. This I've done already. The problem is: when the grid is dismisseed I want another View to come from the top of the screen. This view is in this same root view controller. But I want to display the content of other view controllers in this view. For example: I want this view to show a UINavigationController with a UITableView inside it, so the user can navigate through TableViews.
I'm doing this:
HorariosViewController *horarios = [[HorariosViewController alloc] init];
[vuashView addSubview:horarios.view];
HorariosViewController is a UINavigationViewController. It shows me only a blue NavigationBar and changes like self.navigationItem.title = #"Title" won't work.
Thanks!
You can show another view controller's views as subviews but their outlets and actions remain linked to their original view controller unless you write code to make new connections, so self.whatever shouldn't be expected to affect the other view controller's properties.
(Also, if HorariosViewController is a UINavigationController, it shouldn't be created as a UIViewController.)
One approach is to have the navigation controller already there, with the icon grid presented modally on top of it. (you can set the view up this way without animations, so the user doesn't see the navigation controller underneath).
Then, when it's time for the grid to go away, it can call dismissModalViewController on itself with animation.
I have a modal that I am calling presentModalViewController to display from a custom menubar. This menubar is overlaying a viewcontroller that is pushed from a tableView cell.
Now... that all being said, I need to find some way to jump the user back to the root of the tableView from the modal screen. Is this possible? I've been fighting with this for the past couple of hours with no results.
If you're starting from a tablview, drilling down to a detail view via a navigation controller, and then presenting a modal view controller on top of that detail view, you'd have two steps to get back to your list/tableview: First you'd dismiss your modal view controller, then you'd pop your detail view off your navigation stack.
That should put you back where you started (at the tablview), if I'm reading this correctly.
You could pass a reference to the navigation controller to the modal view, and then immediately after calling dismissModalViewControllerAnimated, you can use the reference to the navigationController to pop back to the root view controller.
I want to hide tabbarcontroller on one view.
But doing so it is displaying white space and not allowing to put any image or anything else on that place.
So what should I do ?
Put one imageView with your desired image on the view controller where you do not want to show tabBar and hide tabBarController before pushing that view on navigation stack using code like
[viewControllerInstanceWhichIsGoingToPushed hidesBottomBarWhenPushed];
The method is something like this. Then Tab Bar will hide and your imageView with image will be displayed in place of TabBar.
If you add a subview to a hidden view, the subview will also go hidden.
In your case, you can have another view controller with just the activity indicator and display the view controller while the loading operation is done. And, after the loading is over, remove that view controller and show the tab bar controller. An example,
// while loading the content
appDelegate.window.rootViewController = loadingViewController;
// once the loading is over
appDelegate.window.rootViewController = tabbarController;
I have encountered this problem before as well and was not able to get anything to get into the blank space using the normal hierarchy. I got around this problem by adding another level of navigation.
ex:
right now you have at UITabBarController which contains your UIViewControllers.
Instead:
Have another UIViewController as the root and then add the tabbarcontroller onto it either as a modalviewcontroller or as a pushed viewcontroller (if you make your root a navigationcontroller). Then, your rootviewcontroller can freely put views under or over the tabbarcontroller's view, independent of whether the bar is present or not.
I've created my own ProfileUIViewController class that is a UINavigationControllerDelegate. I display this view in two ways:
From an IBAction within A-UIViewController.m, as a UIModalViewController. A-UIViewController has a UINavigationBar when it's loaded, but when I display the modal, it no longer has the navigation bar.
From clicking a table cell row within B-UIViewController.m, by pushing it onto the stack. B-UIViewController has a UINavigationBar when it's loaded, and the ProfileViewController keeps the navBar as desired :)
What I am looking to do is keep the UINavigationBar when the view is loaded as a modal in case 1, filling in INSIDE the UINavigationBar instead of laying over the entire view. (IE, I would like the modal to appear within A-UIViewConroller underneath the navBar - making it a smaller size)
Can someone help me with this? Do I need to make my own custom ModalViewController class - wouldn't this be ProfileUIViewController? Does it need some instance methods that I'm not giving it? Any direction would be great:)
The navigation bar is managed by the navigation controller, not by your view controller. When you push your view controller into the navigation controller, the navigation controller uses the information in the navigationItem to determine what to put in the navigation bar. But when you display your view controller modally, it's not inside any navigation controller so there is no bar.
One simple solution for the modal case is to create a new UINavigationController with your view controller as its root view controller, and display that modally instead of displaying your view controller directly.