0

私がやろうとしているのは、iBeacon が見つかったとき (ユーザーがホーム画面にいるとき)、アプリの別の部分に送信するようにすることです。基本的に、ストーリーボードからアプリの別のビューをプッシュします。たとえば、iBeacon1 は View1 をプッシュし、iBeacon2 は View2 をプッシュします。それだけです。私が言ったように、それが可能であることはわかっていますが、iBeacons は非常に新しいため、利用できるヘルプはあまりありません。

答えが見つからないこの問題を解決するために、お時間を割いていただければ幸いです。

時間をありがとう、ジョシュ

4

2 に答える 2

0

ストーリーボードを使用している場合は、次のようなことができます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)
        }
      }
    }
  }
}

ViewControllersaを使用してプログラムでプッシュする代わりに、セグエを使用するようにこれを書き直すこともできますNavigationControllerが、どちらも機能します。

于 2016-01-17T12:06:31.387 に答える