Created
May 11, 2014 22:49
-
-
Save theJasonJones/4990c465d6885f7a84b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ZOOTabBarViewController.h | |
// ZooIBeaconApplication | |
// | |
// Created by Haidong Wang on 4/17/14. | |
// Copyright (c) 2014 Mizzou IT. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> | |
#import "ESTBeacon.h" | |
@interface ZOOTabBarViewController : UITabBarController | |
//@property (strong, nonatomic) IBOutlet UITabBar *tabBar; | |
- (id)initWithBeacon:(ESTBeacon *)beacon; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ZOOTabBarViewController.m | |
// ZooIBeaconApplication | |
// | |
// Created by Haidong Wang on 4/17/14. | |
// Copyright (c) 2014 Mizzou IT. All rights reserved. | |
// | |
#import "ZOOTabBarViewController.h" | |
#import "ESTBeaconManager.h" | |
@interface ZOOTabBarViewController () <ESTBeaconManagerDelegate> | |
@property (nonatomic, strong) ESTBeacon *beacon; | |
@property (nonatomic, strong) ESTBeaconManager *beaconManager; | |
@property (nonatomic, strong) ESTBeaconRegion *beaconRegion; | |
@end | |
@implementation ZOOTabBarViewController | |
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil | |
{ | |
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; | |
if (self) { | |
// Custom initialization | |
} | |
return self; | |
} | |
- (id)initWithBeacon:(ESTBeacon *)beacon | |
{ | |
self = [super init]; | |
if (self) | |
{ | |
self.beacon = beacon; | |
} | |
return self; | |
} | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
[[UITabBar appearance] setSelectedImageTintColor:[UIColor colorWithRed:(141/255.0) green:(198/255.0) blue:(63/255.0) alpha:1]]; | |
// Do any additional setup after loading the view. | |
/* | |
//Beacon Manager setup | |
self.beaconManager = [[ESTBeaconManager alloc] init]; | |
self.beaconManager.delegate = self; | |
self.beaconRegion = [[ESTBeaconRegion alloc] initWithProximityUUID:self.beacon.proximityUUID | |
major:[self.beacon.major unsignedIntValue] | |
minor:[self.beacon.minor unsignedIntValue] | |
identifier:@"RegionIdentifier"]; | |
[self.beaconManager startRangingBeaconsInRegion:self.beaconRegion]; | |
*/ | |
} | |
#pragma mark - ESTBeaconManager delegate | |
- (void)beaconManager:(ESTBeaconManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(ESTBeaconRegion *)region | |
{ | |
if (beacons.count > 0) | |
{ | |
ESTBeacon *firstBeacon = [beacons firstObject]; | |
[self textForProximity:firstBeacon.proximity]; | |
} | |
NSLog(@"No beacons within region"); | |
} | |
#pragma mark - | |
- (void)textForProximity:(CLProximity)proximity | |
{ | |
switch (proximity) { | |
case CLProximityFar: | |
NSLog(@"Far"); | |
break; | |
case CLProximityNear: | |
NSLog(@"Near"); | |
break; | |
case CLProximityImmediate: | |
NSLog(@"Immediate"); | |
break; | |
default: | |
NSLog(@"Unknown"); | |
break; | |
} | |
} | |
- (void)viewDidDisappear:(BOOL)animated | |
{ | |
[self.beaconManager stopRangingBeaconsInRegion:self.beaconRegion]; | |
[super viewDidDisappear:animated]; | |
} | |
- (void)didReceiveMemoryWarning | |
{ | |
[super didReceiveMemoryWarning]; | |
// Dispose of any resources that can be recreated. | |
} | |
/* | |
#pragma mark - Navigation | |
// In a storyboard-based application, you will often want to do a little preparation before navigation | |
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender | |
{ | |
// Get the new view controller using [segue destinationViewController]. | |
// Pass the selected object to the new view controller. | |
} | |
*/ | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment