0

我想要做的是,当找到 iBeacon 时(当用户在主屏幕上时),它将它们发送到应用程序的另一部分。本质上,它从情节提要推动了应用程序的另一个视图。例如,iBeacon1 推送 View1,iBeacon2 推送 View2,等等,仅此而已。就像我说的那样,我知道这是可能的,但是因为 iBeacons 是相当新的,所以没有太多可用的帮助。

如果您能抽出一些时间来帮助我解决这个我找不到答案的问题,我将不胜感激。

谢谢你的时间,乔希

4

2 回答 2

0

语用标记 -

pragma mark - 重要方法

-(void)showSecondController{

if ([_beacon.major isEqual: @3404] && [_beacon.minor isEqual: @10692]) {
    
    if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationPortrait] forKey:@"orientation"];
    
    self.secondViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"SDOVideoDetailController"];
    
} else if ([_beacon.major isEqual: @20165] && [_beacon.minor isEqual: @53849]) {
    
    
    
    if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
        
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationPortrait] forKey:@"orientation"];
    
    
    
    self.secondViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"LRCVideoDetailController"];
    
}  else if ([_beacon.major isEqual: @53088] && [_beacon.minor isEqual: @30487]) {
    
    
    
    
    
    if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
        
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationPortrait] forKey:@"orientation"];
    
    
    
    self.secondViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"CECSVideoDetailController"];
    
    
    
}  else if ([_beacon.major isEqual: @55304] && [_beacon.minor isEqual: @59835]) {
    
    
    
    if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
        
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationPortrait] forKey:@"orientation"];
    
    
    
    self.secondViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"IVideoDetailController"];
    
}  else if ([_beacon.major isEqual: @16004] && [_beacon.minor isEqual: @46054]) {
    
    
    
    if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
        
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationPortrait] forKey:@"orientation"];
    
    
    
    self.secondViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"CILVideoDetailController"];
    
}  else if ([_beacon.major isEqual: @20214] && [_beacon.minor isEqual: @11696]) {
    
    
    
    if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
        
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationPortrait] forKey:@"orientation"];
    
    
    
    self.secondViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ITVideoDetailController"];
    
}  else if ([_beacon.major isEqual: @21559] && [_beacon.minor isEqual: @17557]) {
    
    
    
    if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
        
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationPortrait] forKey:@"orientation"];
    
    
    
    self.secondViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PARKVideoDetailController"];
    
}  else if ([_beacon.major isEqual: @59452] && [_beacon.minor isEqual: @21013]) {
    
    
    
    if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
        
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationPortrait] forKey:@"orientation"];
    
    
    
    self.secondViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"SCVideoDetailController"];
    
}  else if ([_beacon.major isEqual: @42093] && [_beacon.minor isEqual: @49773]) {
    
    
    
    if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
        
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationPortrait] forKey:@"orientation"];
    
    
    
    self.secondViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"BAVideoDetailController"];
    
}
于 2016-05-09T07:21:18.183 回答
0

如果你使用 Storyboards,你可以在你的AppDelegate

var launchedViewControllers = [Int]()

func locationManager(manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], inRegion region: CLBeaconRegion) {
  let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
  if let navController = self.window?.rootViewController?.navigationController {
    for beacon in beacons {
      if (beacon.minor == 1) {
        if !launchedViewControllers.contains(beacon.minor.integerValue) {
          launchedViewControllers.append(beacon.minor.integerValue)
          let viewController1 = mainStoryboard.instantiateViewControllerWithIdentifier("viewController1")
          navController.pushViewController(viewController1, animated: true)
        }
      }
      if (beacon.minor == 2) {
        if !launchedViewControllers.contains(beacon.minor.integerValue) {
          launchedViewControllers.append(beacon.minor.integerValue)
          let viewController2 = mainStoryboard.instantiateViewControllerWithIdentifier("viewController1")
          navController.pushViewController(viewController2, animated: true)
        }
      }
    }
  }
}

您也可以重写它以使用 segues 而不是ViewControllers使用 a以编程方式推送,NavigationController但两者都可以。

于 2016-01-17T12:06:31.387 回答