Reputation: 173
I have Four Tabs in My Project By Default First tab is selected which is Home Class When user navigate to any other class by selecting any tab i have to check that time that if user is loggedin in my application then he will navigate to class which he selected else he move to Login Screen.
if(appDelegate.sessionId==0)
{
Login *objLogin=[[[Login alloc] initWithNibName:@"Login" bundle:nil] autorelease];
[self.navigationController pushViewController:objLogin animated:YES];
}
else
{
CreatePoll *objLogin=[[[CreatePoll alloc] initWithNibName:@"CreatePoll" bundle:nil] autorelease];
[self.navigationController pushViewController:objLogin animated:YES];
}
}
IF i navigate to Login Screen my tab bar gets Hidden and when i debug the code i came to know that Create Poll class is also get called in background i check this link to show tab bar which is hidden but cant get success. Please help me guys i m stucked with this problem from last 3 days. Cant see my tabbar in Login Screen.Please Help
Upvotes: 1
Views: 276
Reputation: 20551
just write this code in viewWillAppear:
method to hide and show the UITabBar
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
[appDelegate.tabBarController.tabBar setHidden:NO];
UPDATE:
post these method in AppDelegate.m
file and when you want to show and hide the Tabbar at that time create AppDelegate object and call this 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 = 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, view.frame.size.width, height)];
}
}
[UIView commitAnimations];
}
Upvotes: 1