iOS 8: Transition from UINavigationController to UISplitViewController, bad animation - ios

I'm trying to animate a transition from a UINavigationController to a UISplitViewController, but the split view controller doesn't draw correctly until the animation is finished. The navigation bars are transparent and their titles are positioned wrong. When the animation finishes, they jump to the "correct" location. I'm using
-transitionFromViewController:toViewController:duration:options:animations:completion
The UISplitViewController has UINavigationControllers for both its master and detail. As it is transitioning in, the navigation bar is dark gray and the title is offset too high. Once the animation finishes, the bar quickly changes color to light gray and the title jumps into the correct place. Here's some example code:
// Master and its nav
UIViewController *master = [[UIViewController alloc] init];
master.title = #"master";
UINavigationController *masterNav = [[UINavigationController alloc] initWithRootViewController:master];
masterNav.toolbarHidden = NO;
// Detail and its nav
UIViewController *detail = [[UIViewController alloc] init];
detail.title = #"detail";
UINavigationController *detailNav = [[UINavigationController alloc] initWithRootViewController:detail];
// Split
UISplitViewController *splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = #[ masterNav, detailNav ];
// Now transition
UIViewController *from = [self.childViewControllers lastObject];
[self addChildViewController:splitViewController];
NSTimeInterval duration = 1.0;
UIViewAnimationOptions options = UIViewAnimationOptionTransitionCrossDissolve;
[self transitionFromViewController:from
toViewController:splitViewController
duration:duration
options:options
animations:^{}
completion:^(BOOL finished) {
[splitViewController didMoveToParentViewController:self];
}];

Related

Adding a persistent footer underneath a UITabBarController

I've inherited a project for which I want to add a persistent footer area beneath the entire app. The app is using a UITabBarController that is always shown other than for a login screen. The tabBarController is created as follows:
UITabBarController *tabBarController = [[UITabBarController alloc] init];
UIStoryboard *sb1 = [UIStoryboard storyboardWithName:#"SB1" bundle:nil];
// ... same for sb2 and sb3
[tabBarController setViewControllers:#[sb1, sb2, sb3]];
[tabBarController setSelectedIndex:0];
I've tried manually setting tabBarController.size.height, but it doesn't seem to have any effect. I've never used storyboards before, is there some way to do initWithFrame when using them? Or am I approaching this completely the wrong way?
Thanks werediver, you got me on the right track. I got it working by adding the UITabBarController as a child view controller and then manually adding its view as well.
const CGFloat FOOTER_HEIGHT = 20;
// Set up tab bar area
CGRect contentFrame = [UIApplication sharedApplication].delegate.window.frame;
contentFrame.size.height -= FOOTER_HEIGHT;
UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.view.frame = contentFrame;
// Set up footer
CGRect footerFrame = contentFrame;
footerFrame.origin.y = contentFrame.size.height;
footerFrame.size.height = FOOTER_HEIGHT;
UIView *footer = [[UIView alloc] initWithFrame:footerFrame];
// Create outer view controller
UIViewController *outer = [[UIViewController alloc] init];
[outer addChildViewController:tabBarController];
[outer.view addSubview:tabBarController.view];
[outer.view footer];
[[UIApplication sharedApplication] keyWindow].rootViewController = outer;

uiview issue with tab bar

I am working on Xcode 5.1.2 iOS7.My problem is that i want to implement tab bar controller on second view controller . Tab bar controller is implemented successfully.My all view are slightly transparent which inserts in array to tab bar.when i click on tab bar button,first view is visible at behind of every view of tab bar views.so how i can solve this problem.
tabbar=[[UITabBarController alloc]init];
UIViewController *first=[[ViewController alloc]init];
UIViewController *second=[[SearchViewController alloc]init];
UIViewController *third=[[Party_partner_ViewController alloc]init];
UIViewController *Fourth=[[My_GrooveViewController alloc]init];
UIViewController *Fifth=[[More_ViewController alloc]init];
UINavigationController *firstNavController = [[UINavigationController alloc] initWithRootViewController:first];
UINavigationController *firstNavController1 = [[UINavigationController alloc] initWithRootViewController:second];
UINavigationController *firstNavController2 = [[UINavigationController alloc] initWithRootViewController:third];
UINavigationController *firstNavController3 = [[UINavigationController alloc] initWithRootViewController:Fourth];
UINavigationController *firstNavController4 = [[UINavigationController alloc] initWithRootViewController:Fifth];
NSArray *ver = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:#"."];
if ([[ver objectAtIndex:0] intValue] >= 7) {
self.nav.navigationBar.barTintColor = [UIColor colorWithRed:29/255.0f green:29/255.0f blue:29/255.0f alpha:1.0f];
self.nav.navigationBar.translucent = NO;
}else
{
self.nav.navigationBar.tintColor = [UIColor colorWithRed:29/255.0f green:29/255.0f blue:29/255.0f alpha:1.0f];
}
self.nav.navigationBar.topItem.title = #"The Groove";
tabbar.viewControllers=[NSArray arrayWithObjects:firstNavController,firstNavController1, firstNavController2,firstNavController3,firstNavController4, Nil];
AppDelegate *mainDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
// UIWindow *window= [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[mainDelegate.window addSubview:tabbar.view];
sure first you can hide or remove your uiview

Tab Bar not hiding Using DDMenuController (Fb like sliding menu)

I am facing this issue from last two days, but could find any solution on it. Can some one help. This is the code snippet am using for TabBar viewControllers.
// Set Up Tab Bar
NSMutableArray *tabBarViewControllers = [[NSMutableArray alloc] initWithCapacity:5];
self.tabBarController = [[UITabBarController alloc] init];
[tabBarController
setDelegate:self];
UINavigationController *navController = nil;
NSArray *vcArray = [self papulateViewControllers];
// SetViewController for tab Bar
-(NSArray *) papulateViewControllers{
BrowseViewController *browseVC = [[BrowseViewController alloc] initWithNibName:#"BrowseViewController" bundle:nil];
AlbumViewController *albumVC = [[AlbumViewController alloc] initWithNibName:#"AlbumViewController" bundle:nil];
SubmitStep1VC *submitVC = [[SubmitStep1VC alloc] initWithNibName:#"SubmitStep1VC" bundle:nil];
// SubmitStep1VC *submitVC = [[SubmitStep1VC alloc] initWithNibName:#"SubmitStep1_iPhone5.xib" bundle:[NSBundle mainBundle]];
WallViewController *wallVC = [[WallViewController alloc] initWithNibName:#"WallViewController" bundle:nil];
OptionVC *optionVC = [[OptionVC alloc] initWithNibName:#"OptionVC" bundle:nil];
sliderVCRef = [[SliderVC alloc] initWithNibName:#"SliderVC" bundle:nil];
//Navigation Controllers
UINavigationController *browseNavController = [[UINavigationController alloc] initWithRootViewController: browseVC];
[browseNavController setNavigationBarHidden:YES];
UINavigationController *albumNavController = [[UINavigationController alloc] initWithRootViewController: albumVC];
[albumNavController setNavigationBarHidden:YES];
UINavigationController *submitNavController = [[UINavigationController alloc] initWithRootViewController: submitVC];
[submitNavController setNavigationBarHidden:YES];
UINavigationController *wallNavController = [[UINavigationController alloc] initWithRootViewController: wallVC];
[wallNavController setNavigationBarHidden:YES];
UINavigationController *optionNavController = [[UINavigationController alloc] initWithRootViewController: optionVC];
[optionNavController setNavigationBarHidden:YES];
DDMenuController *browseMenuController = [[DDMenuController alloc] initWithRootViewController:browseNavController];
self.menuController = browseMenuController;
self.menuController.leftViewController = sliderVCRef;
DDMenuController *albumMenuController = [[DDMenuController alloc] initWithRootViewController:albumNavController];
albumMenuController.leftViewController = sliderVCRef;
DDMenuController *submitMenuController = [[DDMenuController alloc] initWithRootViewController:submitNavController];
submitMenuController.leftViewController = sliderVCRef;
DDMenuController *wallMenuController = [[DDMenuController alloc] initWithRootViewController:wallNavController];
wallMenuController.leftViewController = sliderVCRef;
DDMenuController *optionMenuController = [[DDMenuController alloc] initWithRootViewController:optionNavController];
optionMenuController.leftViewController = sliderVCRef;
/// Works fine if i uncomment this line and comment next line of code (Passing Viewcontrollers is fine )
// return [NSArray arrayWithObjects:self.menuController, albumVC, submitVC, wallVC, optionVC, nil];
////******* issue in case i use this line (Passing menuController creates issue of Tabbar )
return [NSArray arrayWithObjects:self.menuController, albumMenuController, submitMenuController, wallMenuController, optionMenuController, nil];
////////////
}
When i try to push to push to any viewcontroler from any above TabBarController Tab bar is not hiding . example
grandPrizeVC.hidesBottomBarWhenPushed = YES;
Its keep showing me tab bar.
If i try
appDelegate.tabbarcontroller.tabbar.hidden = YES; It shows on a black bottom bar on new VC.
Your app doing just what you have implemented. You are adding your sliding menu view controller as subview controller to tabbar controller, of course, it won't hide. Some suggestions to hide tabbar:
1. Add tabbar controller as modal to your DDMenuController
2. write some methods to hide/show tabbar (searching hide tabbar will give you the answers, or you could just traverse subviews of tabbar controller's view find tabbar and hide it).
Good luck!
Following worked for me :
Show TabBar :
+ (void) showTabBar{
MyAppDelegate* appDelegate = (MyAppDelegate *) [[UIApplication sharedApplication]delegate];
UITabBar *tabBar = appDelegate.tabBarController.tabBar;
UIView *parent = tabBar.superview; // UILayoutContainerView
UIView *content = [parent.subviews objectAtIndex:0]; // UITransitionView
UIView *window = parent.superview;
CGRect tabFrame = tabBar.frame;
tabFrame.origin.y = CGRectGetMaxY(window.bounds) - CGRectGetHeight(tabBar.frame);
tabBar.frame = tabFrame;
CGRect contentFrame = content.frame;
contentFrame.size.height -= tabFrame.size.height;
}
Hide TabBar:
+(void) hideTabBar{
MyAppDelegate* appDelegate = (MyAppDelegate *) [[UIApplication sharedApplication]delegate];
UITabBar *tabBar = appDelegate.tabBarController.tabBar;
UIView *parent = tabBar.superview; // UILayoutContainerView
UIView *content = [parent.subviews objectAtIndex:0]; // UITransitionView
UIView *window = parent.superview;
[UIView animateWithDuration:0.01
animations:^{
CGRect tabFrame = tabBar.frame;
tabFrame.origin.y = CGRectGetMaxY(window.bounds);
tabFrame.origin.y +=20;
tabBar.frame = tabFrame;
content.frame = window.bounds;
}];
}

How do I make the flip animation on a modal view on the iPad transparent in the background?

How do I make my flip animation transparent so the view behind it is shown through?
Here's some of my code:
EditInfoViewController *editController = [[EditInfoViewController alloc] initWithNibName:#"EditInfoViewController" bundle:nil];
editController.delegate = self;
UINavigationController *editNavController = [[UINavigationController alloc] initWithRootViewController:editController];
editNavController.modalPresentationStyle = UIModalPresentationCurrentContext;
editNavController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.navigationController presentModalViewController:editNavController animated:YES];
A picture is worth 1000 words (this was taken during the flip animation):

iPad Navigation controller in splitview popover frame issue

I put a navigation controller as Split-view root-view controller.
When the iPad is in Portrait mode the root view controller is displayed inside a popover controller. Its by default I know....
But My problem is The top of root-view controller is seems hide by popover. See the attched image. In it the home bar-button seems hide a small portion in top.
RootViewController *objRootViewController = [[RootViewController alloc] init];
DetailViewController *objDetailViewController = [[DetailViewController alloc] init];
UINavigationController *rootNavigationController = [[UINavigationController alloc] initWithRootViewController:objRootViewController];
UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:objDetailViewController];
UISplitViewController *objSplitViewController = [[UISplitViewController alloc] init];
[objSplitViewController setDelegate:objDetailViewController];
[objSplitViewController setViewControllers:[NSArray arrayWithObjects:rootNavigationController,detailNavigationController, nil]];
self.splitViewController = objSplitViewController;
[self.window addSubview:self.splitViewController.view];
[objSplitViewController release];
objSplitViewController = nil;
[rootNavigationController release];
rootNavigationController = nil;
[detailNavigationController release];
detailNavigationController = nil;
[objDetailViewController release];
objDetailViewController = nil;
[objRootViewController release];
objRootViewController = nil;

Resources