XCode Simulator

时间:2015-06-17 04:13:00

标签: ios swift xcode6 geofencing

我有点困惑的是,为什么地理围栏不会在模拟器中为iPhone 5以外的任何设备触发。这是XCode版本6.3.2中的错误还是我的代码问题?这是代码:

import UIKit
import MapKit
import CoreLocation

class DirectionsViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate{

var map: MKMapView?
var manager: CLLocationManager?
var destination: MKMapItem?

convenience init(frame:CGRect, destination:MKMapItem){
    self.init(nibName: nil, bundle: nil)
    self.destination = destination
    self.view.frame = frame

    self.map = MKMapView(frame: frame)
    self.map!.delegate = self

    self.view.addSubview(self.map!)

    manager = CLLocationManager()
    manager!.delegate = self
    manager!.desiredAccuracy = kCLLocationAccuracyBest
    manager!.startUpdatingLocation()
    self.map?.showsUserLocation = true
    map!.setUserTrackingMode(MKUserTrackingMode.Follow, animated: true)
        }

func locationManager(manager: CLLocationManager!, didEnterRegion region: CLRegion!) {  
if region is CLCircularRegion {
   println("Entered")

        }
  func viewDidAppear(animated: Bool) {  
    var center: CLLocationCoordinate2D = destination!.placemark.coordinate
    var radius: CLLocationDistance = CLLocationDistance(300)
    var identifier: String = "Destination"
    let region = CLCircularRegion(center: center, radius: radius, identifier: identifier)
    manager?.startMonitoringForRegion(region)
        }

0 个答案:

没有答案