Advertisement
trevor403

iphone tabbar class file

May 2nd, 2013
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  untitled.m
  3. //  
  4. //
  5. //  Created by Trevor Rudolph on 5/3/13.
  6. //  Copyright 2013 TrevorApps. All rights reserved.
  7. //
  8.  
  9. #import "untitled.h"
  10.  
  11.  
  12. @implementation untitled
  13.  
  14. @synthesize tabBar;
  15. @synthesize Item0;
  16. @synthesize Item1;
  17. @synthesize Item2;
  18. @synthesize Item3;
  19. @synthesize Item4;
  20.  
  21. #pragma mark UITabBarDelegate methods
  22.  
  23. - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
  24.     switch (item.tag) {
  25.         case 0:
  26.             NSLog(@"0");
  27.             break;
  28.         case 1:
  29.             break;
  30.         case 2:
  31.             NSLog(@"2");
  32.             break;
  33.         case 3:
  34.             NSLog(@"3");
  35.             break;
  36.         case 4:
  37.             NSLog(@"4");
  38.             break;
  39.         default:
  40.             break;
  41.     }
  42.     NSLog(@"didSelectItem: %d", item.tag);
  43. }
  44.  
  45. #pragma mark UIWebViewDelegate methods
  46.  
  47. - (void)loadView {
  48.     tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 430, 320, 50)];
  49.     tabBar.delegate = self;
  50.     [self.view addSubview:tabBar];
  51.     NSMutableArray *tabBarItems = [[NSMutableArray alloc] init];
  52.     Item0 = [[UITabBarItem alloc] initWithTitle:@"Home" image:[UIImage imageNamed:@"home.png"] tag:0];
  53.     Item1 = [[UITabBarItem alloc] initWithTitle:@"Quests" image:[UIImage imageNamed:@"missions.png"] tag:1];
  54.     Item2 = [[UITabBarItem alloc] initWithTitle:@"Battle" image:[UIImage imageNamed:@"attack.png"] tag:2];
  55.     Item3 = [[UITabBarItem alloc] initWithTitle:@"Armory" image:[UIImage imageNamed:@"equipment.png"] tag:3];
  56.     Item4 = [[UITabBarItem alloc] initWithTitle:@"Recuit" image:[UIImage imageNamed:@"recruit.png"] tag:4];
  57.     [tabBarItems addObject:Item0];
  58.     [tabBarItems addObject:Item1];
  59.     [tabBarItems addObject:Item2];
  60.     [tabBarItems addObject:Item3];
  61.     [tabBarItems addObject:Item4];
  62.     tabBar.items = tabBarItems;
  63.     tabBar.selectedItem = [tabBarItems objectAtIndex:0];
  64. }
  65.  
  66. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement