I've got a UIViewController that has a modal window which I'd like to present over the entire interface, including the UITabBar.
My application hierarchy is this:
UITabBarController (A) ->
UIViewController (B) ->
UINavigationController (C) ->
UIViewController (D) ->
UIViewController (my modal view)
When I call presentModalViewController on D, the modal view is presented but underneath the UITabBar, or should I say, the UITabBar is still shown.
I've tried setting the hidesBottomBarWhenPushed property to YES on the modal view controller, but to no avail.
Any ideas on why this isn't working for me?
The modal ViewController needs to be a direct child of the TabBarController in order to do what you want.
in ViewController "D", instead of :
[self presentModalViewController:...];
do:
[tabBarController presentModalViewController:...];
how you maintain a reference to the TabBarController is up to you.
Related
I have implemented a custom viewController transition whereby I present a new ViewController as a pop-over. This resembles something like an alertViewController. I have written the transition handler and set my presenting viewController as the delegate and than preset this presented view controller like this:
#IBAction func pickOption(sender: UIButton) {
let storyBoard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyBoard.instantiateViewControllerWithIdentifier("OptionVC")
vc.modalPresentationStyle = .OverCurrentContext
vc.transitioningDelegate = self
self.presentViewController(vc, animated: true, completion: nil)
}
Here is where I am confused about proceeding with the layout. I wish to have this presented ViewController take up a small fraction of the frame of the presenting ViewController's View, preferably using Autolayout to set margin constraints. However, both the ViewController's in this are separate scenes in Interface Builder.
In the transition handler, the canonical thing to do seems to be adding the presented ViewController's view to a "context" view and handle animations there. Then call transitionContext.completeTransition(). Now that the presented ViewController's view is a subview of the presenting ViewController's view, I would like the autolayout constraints to be present but as I previously stated this isn't obvious how to do given both views are in separate scenes in IB.
Thanks in advance for any advice for guidance.
I want to create a segue from (a) a UIButton (in a custom cell of a tableview) and (b) a custom cell in general to a UIViewController. The custom cell is specified in a .xib file. I read that I just should control drag from the UIButton / custom cell to the UIViewController. That doesn't work for me.
The .xib file of the custom cell isn't inside the storyboard - that's right?
I thought about that it should be inside the storyboard. If necessary, how can I do that?
How can I create a segue from the UIButton (in a custom cell) / custom cell to the UIViewController?
Thanks!
EDIT: I'm using a UITableViewController as Source, the destination is a UIViewController with a UITableView.
Ctrl-drag from the tableViewController (not from the prototype cell) to your target viewController and assign an identifier name to the segue.
Now override didSelectRowAtIndexPathto perform the segue with your identifier when tapping that cell:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
performSegueWithIdentifier("yourSegue", sender: nil)
}
Distinguish between the cells based on your indexPath and create as many segues as you need to your target viewControllers.
You can do similar for the button in your custom cell. Perform the segue on the button's action.
I used xcode6beta5 that should be the problem. Now I'm using xCode6 GM and the creation of the segues works absolutely fine like zisoft wrote! Thanks man!!
i have NavigationController base application but i need TabBar in the bottom only on the Two Scene not for the whole app. Anyone have any idea about it.
Waiting your kind response.
i have found a solution By creating a very simple thing as making a UIView using storyboard and add Button of custom type and then push and pop ViewControllers by using Following button actions
- (IBAction)pushToSecondVC:(id)sender {
UIViewController *tab2vc = [[UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:#"SecondViewController"];
[self.navigationController pushViewController:tab2vc animated:NO];
}
and for the back button in the second ViewController
-(IBAction)goBackToPreviousController:(id)sender{
[self.navigationController popViewControllerAnimated:NO];
}
i have a TabBar with 5 ViewControllers. i am using that array of tabBarController to populating a SideBarMenu like in Facebook app.
When i use a viewController to set as RootViewController of UINavigationController, then this viewController gets removed from the array [self.tabBarController viewControllers].
Why is this happening and how can i prevent this?
return [[UINavigationController alloc] initWithRootViewController:
[[self.tabBarController viewControllers] objectAtIndex:0]];
the viewController at objectIndex 0 gets removed and the [self.tabbarcontroller viewControllers] is returning only 4 viewControllers.
A UIViewController can only have one parent. When you add the view controller from the tab bar to the navigation controller, the navigation controller detached the view controller from its previous parent and attaches it to itself. For more information about why this happens, read the Implementing a Container View Controller section of the UIViewController documentation.
I want to resize a UIViewController in the storyboard so I can use its UIViewController as a popover view.
On most sites I can read that the actions are:
drag a UIViewController in the storyboard
put a UIView on it
set the attribute on freeform and resize
But in my iOS 5.1 this does not work, even with a new project with only one UIViewController.
What did I forget in the procedure?
We follow the following steps to achieve the same:
Drag a UIViewController (this takes a UIView along with it, so no need to add another UIView unless you need more)
Select UIViewController on StoryBoard and set size property to Freeform
Select the UIView and set the height and width values.
If this doesn't help, you might want to delete the UIView that comes with the UIViewController, add a fresh UIView and repeat #2, and #3 above.
Drag a UIViewController
2 .Select UIViewController on StoryBoard and set size property to Freeform
select UIViewController on storyboard Enable user preferred explicit size in Content size in attributes inspector
You need to take off "Resize View from NIB" in IB attributes tab.