remove tabbar controller from uiviewcontroller - iphone

I am adding a tabbarcontroller from a uiview controller. Please check my code:
UITabBarController *tabBarController = [[UITabBarController alloc] init];
NSMutableArray *arrControllers = [[NSMutableArray alloc] init];
for(int i = 0; i<arrTabs.count;i++){
NSArray *arr = [arrTabs objectAtIndex:i];
if([[arr objectAtIndex:0] isEqualToString:#"PICS"]){
picTabViewController *pics = [[picTabViewController alloc] initWithNibName:#"picTabViewController" bundle:nil];
UINavigationController *picsNVC = [[UINavigationController alloc] initWithRootViewController:pics];
picsNVC.tabBarItem.image = [UIImage imageNamed:#"tab-news.png"];
picsNVC.tabBarItem.title = [arr objectAtIndex:1];
[arrControllers addObject:picsNVC];
}
if([[arr objectAtIndex:0] isEqualToString:#"MAP"]){
mapTabViewController *maps = [[mapTabViewController alloc] initWithNibName:#"mapTabViewController" bundle:nil];
UINavigationController *mapsNVC = [[UINavigationController alloc] initWithRootViewController:maps];
mapsNVC.tabBarItem.image = [UIImage imageNamed:#"tab-news.png"];
mapsNVC.tabBarItem.title = [arr objectAtIndex:1];
[arrControllers addObject:mapsNVC];
}
if([[arr objectAtIndex:0] isEqualToString:#"HTML"]){
htmlTabViewController *html = [[htmlTabViewController alloc] initWithNibName:#"htmlTabViewController" bundle:nil];
UINavigationController *htmlNVC = [[UINavigationController alloc] initWithRootViewController:html];
htmlNVC.tabBarItem.image = [UIImage imageNamed:#"tab-news.png"];
htmlNVC.tabBarItem.title = [arr objectAtIndex:1];
[arrControllers addObject:htmlNVC];
}
}
tabBarController.viewControllers = arrControllers;
self.tabBarController.selectedIndex = 0;
[self.view.window addSubview:tabBarController.view];
The tab bar controller is added as desired. But now I want to add a button to go back to previous page, or you can say remove tabbar and its viewcontrollers from the viewcontroller on which it was added. Can someone please suggest me how can I do it?
Please remember that I have added the tabbarcontroller from viewcontroller and not app delegate.
Regards
Pankaj

I've taken one tabbar and alloc-init once, then I'll show & hide on different UIViews.So there is no need to remove & alloc all the time.
Show Tabbar
[self showTabBar:self.tabBarController];
Hide Tabbar
[self hideTabBar:self.tabBarController];
Code for Showing -> It'll automatically appear by setting its 'Y'::
- (void) showTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.4];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
if ([[UIScreen mainScreen] bounds].size.height == 568)
{
[view setFrame:CGRectMake(view.frame.origin.x, 519, view.frame.size.width, view.frame.size.height)];
}
else if ([[UIScreen mainScreen] bounds].size.height == 480)
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
}
}
else
{
if ([[UIScreen mainScreen] bounds].size.height == 568)
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 519)];
}
else if ([[UIScreen mainScreen] bounds].size.height == 480)
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
}
}
}
[UIView commitAnimations];
}
Code for Hiding -> It'll automatically disappear by setting its 'Y'::
- (void) hideTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.4];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
if ([[UIScreen mainScreen] bounds].size.height == 568)
{
[view setFrame:CGRectMake(view.frame.origin.x, 568, view.frame.size.width, view.frame.size.height)];
}
else if ([[UIScreen mainScreen] bounds].size.height == 480)
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
}
else
{
if ([[UIScreen mainScreen] bounds].size.height == 568)
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 568)];
}
else if ([[UIScreen mainScreen] bounds].size.height == 480)
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
}
[UIView commitAnimations];
}
Hopefully, it'll help you if don't want to alloc & release all the time during application.
Thanks.

Just put this method in AppDelegate.m file and call this method when you want to remove tabbarcontroller from superview and set another view as a parentviewController
-(void)setMainView
{
yourViewController *masterViewController = [[[yourViewController alloc] initWithNibName:#"yourViewController" bundle:nil] autorelease];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
self.navigationController.navigationBar.hidden=YES;
self.window.rootViewController = self.navigationController;
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setType:kCATransitionFade];
[animation setDuration:0.5];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:
kCAMediaTimingFunctionEaseInEaseOut]];
[[self.window layer] addAnimation:animation forKey:kAnimationKey];
}
and call above method with object of AppDelegate class For Ex..
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate setMainView];
i hope this helped you..

Related

The tabBarController is not displayed

i want to make tabbarcontroller programatically. The tabBarController is not displayed in the page. can anyone tell that whts going wrong.and can we make more than one tabbarcontroller in an application
ViewController.m
- (void)viewDidLoad
{
report=[[UIViewController alloc]initWithNibName:#"ViewController" bundle:nil];
View1 *template=[[View1 alloc]initWithNibName:#"View1" bundle:nil];
View2 *acc=[[View2 alloc]initWithNibName:#"View2" bundle:nil];
View3 *four=[[View3 alloc]initWithNibName:#"View3" bundle:nil];
View4 *five=[[View4 alloc]initWithNibName:#"View4" bundle:nil];
nav1=[[UINavigationController alloc]initWithRootViewController:report];
nav2=[[UINavigationController alloc]initWithRootViewController:template];
nav3=[[UINavigationController alloc]initWithRootViewController: acc];
nav4=[[UINavigationController alloc]initWithRootViewController:four];
nav5=[[UINavigationController alloc]initWithRootViewController:five];
UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:#"Title" image:[UIImage imageNamed:#"singleicon.png"] tag:0];
UITabBarItem *item1 = [[UITabBarItem alloc] initWithTitle:#"Reports" image:[UIImage imageNamed:#"doubleicon.png"] tag:1];
UITabBarItem *item2 = [[UITabBarItem alloc] initWithTitle:#" New " image:[UIImage imageNamed:#"clockicon.png"] tag:2];
UITabBarItem *item3=[[UITabBarItem alloc]initWithTitle:#"four" image:[UIImage imageNamed:#"dependenticon.png"] tag:3];
UITabBarItem *item4=[[UITabBarItem alloc]initWithTitle:#"five" image:[UIImage imageNamed:#"toolicon.png"] tag:4];
nav1.tabBarItem = item;
nav2.tabBarItem = item1;
nav3.tabBarItem = item2;
nav4.tabBarItem=item3;
nav5.tabBarItem=item4;
//[item1 setBadge:#"25"];
self.tabBarController=[[UITabBarController alloc]init];
[self.tabBarController setViewControllers:[NSArray arrayWithObjects:nav1,nav2,nav3,nav4,nav5,nil]];
self.report = self.tabBarController;
// [self.report makeKeyAndVisible];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
Use below code:
self.tabBarController.viewControllers = [NSArray arrayWithObjects:nav1,nav2,nav3,nav4,nav5,nil]];
self.window.rootViewController = self.tabBarController;
UPDATE:
also for Hide and Show the UITabBar then use bellow code ..
just put this methods in AppDelegate.m file and when you want to hide tabbar at that time just create AppDelegate object and call bellow hideTabBar method
- (void) hideTabBar:(UITabBarController *) tabbarcontroller {
int height = 480;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
for(UIView *view in tabbarcontroller.view.subviews) {
if([view isKindOfClass:[UITabBar class]]) {
[view setFrame:CGRectMake(view.frame.origin.x, height, view.frame.size.width, view.frame.size.height)];
}
else {
[view setFrame:CGRectMake(view.frame.origin.x,view.frame.origin.y, 320, 436)];
}
}
[UIView commitAnimations];
}
- (void) showTabBar:(UITabBarController *) tabbarcontroller {
int height = 436;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
for(UIView *view in tabbarcontroller.view.subviews) {
if([view isKindOfClass:[UITabBar class]]) {
[view setFrame:CGRectMake(view.frame.origin.x, height, view.frame.size.width, view.frame.size.height)];
}
else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, height)];
}
}
[UIView commitAnimations];
}
put all the coding in the action of the button and push the tabBarController like that:-
[self.navigationController pushViewController:tabBarController animated:YES];
If you want to add UITabBarController programmatically, then you need to add your tabbarcontroller to your ViewController. you need to use this line,
[self.view addSubview:self.tabBarController.view];
You need to add tabBarController in view you have missed the one line
i just did this
[self.navigationController pushViewController:tabBarController animated:YES];

Animated Splash Screen in iPhone

I need to implement animated splash screen to the iPhone application. I have seen skype application where same thing is already implemented.
Can anyone has idea how can i implement same thing in my applicatio
You can use sequence of images, here is code :
for(NSInteger i=1;i<=totalImages;i++){
NSString *strImage = [NSString stringWithFormat:#"Activity_%d",i];
UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:strImage ofType:#"png"]];
[imageArray addObject:image];
}
splashImageView.animationImages = imageArray;
splashImageView.animationDuration = 0.8;
and just call startAnimation and endAnimation method of UIImageView.
OR
Its very simple...I had used it in to begin my app with splashView.Hope it vil help you.... In AppDelegate.m:
application didFinishLaunchingWithOptions:
UIImage* image=[UIImage imageNamed:#"splash.jpg"];
splashView=[[UIImageView alloc]initWithImage:image];
[window addSubview:splashView];
[window bringSubviewToFront:splashView];
[self performSelector:#selector(removeSplash) withObject:self afterDelay:2];
[window makeKeyAndVisible];
To remove splashView:
-(void)removeSplash{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window cache:YES];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
[splashView removeFromSuperview];
[UIView commitAnimations];
[window addSubview:viewController.view];
}
We can show a .gif image in webView and it looks perfect!
Take a new UIViewController class named SplashView with XIB and then add an UIWebView with (320.0, 480.0) frame, hidden statusbar also.
In SplashView.h
#import <UIKit/UIKit.h>
#interface SplashView : UIViewController
#property(nonatomic, retain)IBOutlet UIWebView *webView;
#end
In SplashView.m
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *imagePath = [[NSBundle mainBundle] pathForResource: #"animated" ofType: #"gif"];
NSData *data = [NSData dataWithContentsOfFile:imagePath];
[self.webView setUserInteractionEnabled:NO];
[self.webView loadData:data MIMEType:#"image/gif" textEncodingName:nil baseURL:nil];
}
This is about SplashView class. Now come to your appdelegate's class.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
splashView = [[SplashView alloc]initWithNibName:#"SplashView" bundle:nil];
[self.window addSubview:splashView.view];
[self performSelector:#selector(changeView) withObject:nil afterDelay:3.0];
[self.window makeKeyAndVisible];
return YES;
}
-(void)changeView
{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[splashView.view removeFromSuperview];
[self.window setRootViewController:self.viewController];
}
Take a UIView & an Imageview into it. Give all your images to ImageView to animate.
-(void)viewDidLoad
{
NSArray *arrImage=[NSArray arrayWithObjects:
[UIImage imageNamed:#"1.png"],
[UIImage imageNamed:#"2.png"],
[UIImage imageNamed:#"3.png"],
nil];
imgVw.backgroundColor=[UIColor purpleColor];
imgVw.animationImages=arrImage;
imgVw.animationDuration=2.5;
imgVw.animationRepeatCount=1;
[imgVw startAnimating];
[NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:#selector(animateNext) userInfo:nil repeats:NO];
}
This will show up you application icon.
After that you will show the controls those would be hidden by default and animate them from bottom to up.
-(void)animateNext
{
lbl.hidden = NO;
btn.hidden = NO;
txt1.hidden = NO;
txt2.hidden = NO;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.9];
lbl.frame=CGRectMake(lbl.frame.origin.x,lbl.frame.origin.y - 150,lbl.frame.size.width,lbl.frame.size.height);
imgVw.frame = CGRectMake(imgVw.frame.origin.x, imgVw.frame.origin.y - 150, imgVw.frame.size.width, imgVw.frame.size.height);
txt1.frame = CGRectMake(txt1.frame.origin.x, txt1.frame.origin.y - 150, txt1.frame.size.width, txt1.frame.size.height);
txt2.frame = CGRectMake(txt2.frame.origin.x, txt2.frame.origin.y - 150, txt2.frame.size.width, txt2.frame.size.height);
btn.frame = CGRectMake(btn.frame.origin.x, btn.frame.origin.y - 150, btn.frame.size.width, btn.frame.size.height);
[UIView commitAnimations];
}
Hope this help...
Try this
Appdelegate.h
#interface AppDelegate : UIResponder <UIApplicationDelegate>
{
UIImageView *splashView;
}
#property (strong, nonatomic) UIWindow *window;
#property (strong, nonatomic) ViewController *viewController;
- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context;
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
// Make this interesting.
splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)];
splashView.image = [UIImage imageNamed:#"Default.png"];
[self.window addSubview:splashView];
[self.window bringSubviewToFront:splashView];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.window cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(startupAnimationDone:finished:context:)];
splashView.alpha = 0.0;
splashView.frame = CGRectMake(-60, -85, 440, 635);
[UIView commitAnimations];
return YES;
}
- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[splashView removeFromSuperview];
}
you need to start your app with a viewcontroller,with an uiimageview in it..Create a series of .png images to be subjected to the UIImageView check how to animate array of images in uiimageview. Further to dismiss it once animation over you would need to implement a protocol that will inform your starting first viewcontroller of your app to dismiss the animation
- (void) welcomeScreen
{
//Welcome Screen
UIImageView* welcome = [[[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)]autorelease];
welcome.image = [UIImage imageNamed:#"img.png"];
[window addSubview:welcome];
[window bringSubviewToFront:welcome];
//Animation Effects (zoom and fade)
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:window cache:YES];
[UIView setAnimationDelegate:welcome];
[UIView setAnimationDidStopSelector:#selector(removeFromSuperview)];
//set transparency to 0.0
welcome.alpha = 0.0;
//zoom effect
welcome.frame = CGRectMake(-60, -60, 440, 600);
[UIView commitAnimations];
}
yes simple in AppDelegate class first defile imageview like bellow..
#interface AppDelegate : UIResponder
{
UIImageView *splashView;
}
and in .m file...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
splashView.image = [UIImage imageNamed:#"Default"];
[self.window addSubview:splashView];
[self performSelector:#selector(loadViewIphone) withObject:nil afterDelay:2.0];
}
[self.window makeKeyAndVisible];
return YES;
}
-(void)loadViewIphone
{
[splashView removeFromSuperview];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setType:kCATransitionFade];
[animation setDuration:0.5];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:
kCAMediaTimingFunctionEaseInEaseOut]];
[[self.window layer] addAnimation:animation forKey:#"transitionViewAnimation"];
}
i hope this help you..
:)

How to load a tabbar controller xib using navigation controller

I am new to ios, I had a problem with tabbar controller. I am using two tab bar controller in my project.One is loaded at app lunch and it is working good.I want to load another at didselect row.How to do this. I have done many experiments but nothing works.
-(void) hidetabbar {
[UIView animateWithDuration:0.5
animations:^{
for(UIView *view in tabBarController.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
if (hiddenTabBar) {
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
} else {
if (hiddenTabBar) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
}
}];
hiddenTabBar = !hiddenTabBar;
}
when u r clicking on the table view did select row hide the tabbar in the viewcontroller that u r sending
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:YES];
[((AppDelegate*)[[UIApplication sharedApplication]delegate]) hidetabbar];
}
-(void)tabBarControllerView
{
tabBarController = [[UITabBarController alloc] init];
tabBarController.view.backgroundColor = [UIColor blackColor];
tabBarController.delegate = self;
//Add some tabs to the controller...
//----First tab----//
//-----second Tab -----//
//------3rd tab--//
//-----4th tab bar--------//
//-----5th tab bar--------//
[self.view addSubview:tabBarController.view];
[navigationController pushViewController:tabBarController animated:YES];
tabBarController.tabBar.tag=100;
tabBarController.view.hidden = NO;
}
- (void)tabBarController:(UITabBarController *)tabBarControllers didSelectViewController:(UIViewController *)viewController
{
if (tabBarControllers.selectedIndex == 0)
{
}
else if (tabBarControllers.selectedIndex == 1)
{
}
else if (tabBarControllers.selectedIndex == 2)
{
}
else if (tabBarControllers.selectedIndex == 3)
{
}
else if (tabBarControllers.selectedIndex == 4)
{
}
}
hide main tab bar in that view controller where u r doing the did select table and add another tab bar..
try some thing like this it may help u
Add the following Code in didSelect event
UITabBarController *tabBarController = [[UITabBarController alloc]init];
NSArray*tabBarimageArray=[NSArray arrayWithObjects:#"firstTabImage.png",#"secondTabImage.png", nil];
YourFirstTabRootViewController *firstVc = [[YourFirstTabRootViewController alloc]initWithNibName:#"YourFirstTabRootViewController" bundle:nil];
UINavigationController *firstNavigationController=[[UINavigationController alloc]initWithRootViewController:firstVc];
YourSecondTabRootViewController *secondVc = [[YourSecondTabRootViewController alloc]initWithNibName:#"YourFirstTabRootViewController" bundle:nil];
UINavigationController *secondNavigationController=[[UINavigationController alloc]initWithRootViewController:secondVc];
NSArray *VCs = [[NSArray alloc] initWithObjects:firstNavigationController,secondNavigationController nil];
NSArray *names = [NSArray arrayWithObjects:
NSLocalizedString(#"Tab1", #""),
NSLocalizedString(#"Tab2", #""),
nil];
NSMutableArray *tabBarViewControllers = [[NSMutableArray alloc] initWithCapacity:[VCs count]];
NSInteger index = 0;
for (id controller in VCs) {
UINavigationController * navController = controller ;
// THIS SETS UP THE TAB BAR ITEMS/IMAGES AND SET THE TAG FOR TABBAR_ITEM_TAGS
NSString *tabName = [names objectAtIndex:index];
UIImage *tabImage = [UIImage imageNamed:[NSString stringWithFormat:[tabBarimageArray objectAtIndex:index]]];
navController.title = tabName;
UITabBarItem *tempTab = [[UITabBarItem alloc] initWithTitle:tabName
image:tabImage
tag:index];
navController.tabBarItem = tempTab;
[tabBarViewControllers addObject:navController];
index ++;
}
[ tabBarController setViewControllers:tabBarViewControllers];
[self presentModalViewController:tabBarController animated:YES];

UITabBar wont hide

I have a UINavigationController in a UITabBarController, and I can't seem to get a pushed viewController's tabBar to hide.
I am using the following code to hide it:
Before it gets pushed:
tpsv.hidesBottomBarWhenPushed = YES;
tpsv.tabBarController.hidesBottomBarWhenPushed = YES;
viewWillAppear:
self.tabBarController.tabBar.hidden = YES;
AppDelegate *del = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[[[del tabController] tabBar]setHidden:YES];
But none of the above work.
If you could tell me how to fix this, that would be great.
You set this before you push the new view controller:
MyViewController *myVC = [[[MyViewController alloc] init] autorelease];
myVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:myVC animated:YES];
[EDIT: comment re usage]
Just noticed you say you tried this. Not sure what else you're doing in the context of pushing your VC or configuring it but this does work fine. It's how I do this exact thing in my apps.
- (void) hideTabBar:(UITabBarController *) tabbarcontroller {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
[UIView commitAnimations];
}
- (void) showTabBar:(UITabBarController *) tabbarcontroller {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
NSLog(#"%#", view);
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
}
}
[UIView commitAnimations];
}
I've faced the same problem with
myVC.hidesBottomBarWhenPushed = YES;
It does'nt remove the tab bar in subsequent views. May be it's deprecated. You should'nt face this problem with the setHidesBottomBarWhenPushed: command. Try using the following for views:
MyViewController *myVC = [[[MyViewController alloc] init] autorelease];
[myVC setHidesBottomBarWhenPushed:YES];
[self.navigationController pushViewController:myVC animated:YES];

Iphone TabBar Application

I start to develop app in tab bar application template..
Here my first page is login page after loagin it go to home page and all navigation will happen..
Here i don't want tab bar only in login page.How to doo this?
Thanks.....
on the first tab, add whatever check you need for whether or not they are logged in, and if not, present a modal view with the login fields.
//some test here to determine state of self.registered
if(self.registered==FALSE){
LoginViewController *login = [[LoginViewController alloc] initWithNibName: #"loginView" bundle: nil];
login.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self.navigationController presentModalViewController:login animated:YES];
[login release];
}
With this you can hide and how uitabbarcontroller -
- (void) hideTabBar:(UITabBarController *) tabbarcontroller {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
[UIView commitAnimations];
}
- (void) showTabBar:(UITabBarController *) tabbarcontroller {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
NSLog(#"%#", view);
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
}
}
[UIView commitAnimations];
}
You can do like this:
In delegate.h declare your views,
UIView *indicatorView;
UIImageView *splashV;
now in delegate.m
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
indicatorView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
splashV=[[UIImageView alloc]initWithFrame:CGRectMake(0, 20, 320, 460)];
[splashV setImage:[UIImage imageNamed:#"Default.png"]];
[indicatorView setBackgroundColor:[UIColor clearColor]];
[indicatorView addSubview:splashV];
[self.window addSubview:indicatorView];
}
& on successful login
-(void)SuccessfulLoginDone
{
[window addSubview:[tabBarController view]];
[window makeKeyAndVisible];
}
Hope that would be much better to do this task.