[Solved] How can I implement 4 Round Rect Buttons which behave like tabbars items? [closed]


Just check with complete code. which acts like tabbar controller.

localViewControllersArray = [[NSMutableArray alloc] initWithCapacity:0];

AllRumsController *allRumsScreen=[[AllRumsController alloc]init];
RumRecipesController *rumRecipesScreen =[[RumRecipesController alloc] init];
PartyPlannerClass *aPartyPlannerScreen =[[PartyPlannerClass alloc] init];
BarTendingClass *aBarTendingScreen =[[BarTendingClass alloc] init];
MoreControllersClass *moreControllerScreen =[[MoreControllersClass alloc] init];

controllersArray = [[NSArray alloc]initWithObjects:allRumsScreen,rumRecipesScreen,aPartyPlannerScreen,aBarTendingScreen,moreControllerScreen,nil];

for(int i=0;i<[controllersArray count];i++)
{
UINavigationController *localNavigationController=[[UINavigationController alloc]initWithRootViewController:[controllersArray objectAtIndex:i]];
localNavigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
    if(!i)
        [localNavigationController setTitle:@"All Rums"];
    else if(i ==1)
        [localNavigationController setTitle:@"Recipes"];
    else if(i ==2)
        [localNavigationController setTitle:@"PartyPlanner"];
    else if(i ==3)
        [localNavigationController setTitle:@"BarTending"];
    else 
        [localNavigationController setTitle:@"More"];
       localNavigationController.navigationBar.hidden = YES;
       [localViewControllersArray addObject:localNavigationController];

     [localNavigationController release];
 }
[allRumsScreen release];
[rumRecipesScreen release];
[aPartyPlannerScreen release];
[aBarTendingScreen release];
[moreControllerScreen release];

if(contentView == nil)
{
    contentView = [[UIView alloc] initWithFrame:CGRectMake(0,0,MAX_WIDTH, 431)];
    contentView.backgroundColor = [UIColor clearColor];
}
if(bottomView == nil)
{   
    bottomView = [[UIView alloc] initWithFrame:CGRectMake(0,431,MAX_WIDTH, 49)];
    bottomView.backgroundColor = [UIColor clearColor];
}

allButtonsArray = [[NSMutableArray alloc]initWithCapacity:0];

for(int i=0;i<[localViewControllersArray count];i++)
{
    UIButton *aButton=[UIButton buttonWithType:UIButtonTypeCustom];
    aButton.frame=CGRectMake(i*64,0,64,49);
    [aButton setTag:i];
    if(!i)
    {
        [aButton setImage:[UIImage imageNamed:@"ourrums_n.png"] forState:UIControlStateNormal];
        [aButton setImage:[UIImage imageNamed:@"ourrums_a.png"] forState:UIControlStateHighlighted];
        [aButton setImage:[UIImage imageNamed:@"ourrums_n.png"] forState:UIControlStateDisabled];
    }
    else if(i ==1)
    {
        [aButton setImage:[UIImage imageNamed:@"Recipies_n.png"] forState:UIControlStateNormal];
        [aButton setImage:[UIImage imageNamed:@"Recipies_a.png"] forState:UIControlStateHighlighted];
        [aButton setImage:[UIImage imageNamed:@"Recipies_n.png"] forState:UIControlStateDisabled];

    }else if(i ==2)
    {
        [aButton setImage:[UIImage imageNamed:@"myevents_n.png"] forState:UIControlStateNormal];
        [aButton setImage:[UIImage imageNamed:@"myevents_a.png"] forState:UIControlStateHighlighted];
        [aButton setImage:[UIImage imageNamed:@"myevents_n.png"] forState:UIControlStateDisabled];

    }else if(i ==3)
    {
        [aButton setImage:[UIImage imageNamed:@"bartending_n.png"] forState:UIControlStateNormal];
        [aButton setImage:[UIImage imageNamed:@"bartending_a.png"] forState:UIControlStateHighlighted];
        [aButton setImage:[UIImage imageNamed:@"bartending_n.png"] forState:UIControlStateDisabled];

    }else 
    {
        [aButton setImage:[UIImage imageNamed:@"more_n.png"] forState:UIControlStateNormal];
        [aButton setImage:[UIImage imageNamed:@"more_a.png"] forState:UIControlStateHighlighted];
        [aButton setImage:[UIImage imageNamed:@"more_n.png"] forState:UIControlStateDisabled];
    }
    [aButton addTarget:self action:@selector(showViewOfButton:) forControlEvents:UIControlEventTouchUpInside];
    [allButtonsArray addObject:aButton];
    [bottomView addSubview:aButton];
}

[[[[UIApplication sharedApplication] delegate] window] addSubview:contentView];
[[[[UIApplication sharedApplication] delegate] window] addSubview:bottomView];

[bottomView setHidden:YES];
[contentView setHidden:YES];


[self showViewOfButton:[allButtonsArray objectAtIndex:0]];





-(void)showViewOfButton:(id)sender
    {
if(start == YES)
{
    start = NO;
    [repeat setTag:[sender tag]];
}
else if([repeat tag] == [sender tag])
{
    return;
}
else
{
    [repeat setTag:[sender tag]];
}

if(previous!=nil)
{
    [previous setImage:[previous imageForState:UIControlStateDisabled] forState:UIControlStateNormal];
}


if( [[contentView subviews] count] )
{
    if([[RumsDataHolder sharedHolder] mailController])
    {
        [[[[RumsDataHolder sharedHolder] mailController] retain] dismissModalViewControllerAnimated:NO];
    }
    [[[contentView subviews] objectAtIndex:0] removeFromSuperview];
}

if( ((UIView *)sender).tag == 0)
{
    [sender setImage:[UIImage imageNamed:@"ourrums_a.png"] forState:UIControlStateNormal];
    [contentView addSubview:[[localViewControllersArray objectAtIndex:0] view]];
}
else if( ((UIView *)sender).tag == 1)
{
    [sender setImage:[UIImage imageNamed:@"Recipies_a.png"] forState:UIControlStateNormal];
    [contentView addSubview:[[localViewControllersArray objectAtIndex:1] view]];
}
else if(((UIView *)sender).tag == 2)
{
    [sender setImage:[UIImage imageNamed:@"myevents_a.png"] forState:UIControlStateNormal];
    [contentView addSubview:[[localViewControllersArray objectAtIndex:2] view]];
}
else if( ((UIView *)sender).tag == 3)
{
    [sender setImage:[UIImage imageNamed:@"bartending_a.png"] forState:UIControlStateNormal];
    [contentView addSubview:[[localViewControllersArray objectAtIndex:3] view]];
}
else if(((UIView *)sender).tag == 4)
{
    [sender setImage:[UIImage imageNamed:@"more_a.png"] forState:UIControlStateNormal];
    [contentView addSubview:[[localViewControllersArray objectAtIndex:4] view]];
}
else
    ;
previous=sender;
}

2

solved How can I implement 4 Round Rect Buttons which behave like tabbars items? [closed]