小编Col*_*ane的帖子

CLLocationManager startUpdatingLocation不起作用

所以现在我至少得到以下代码的回调...

- (void)viewDidLoad {

[super viewDidLoad];
mapView=[[MKMapView alloc] initWithFrame:self.view.frame];
//mapView.showsUserLocation=TRUE;
mapView.delegate=self;
[self.view insertSubview:mapView atIndex:0];

NSLog(@"locationServicesEnabled: %@", [CLLocationManager locationServicesEnabled] ? @"YES":@"NO");
    CLLocationManager *newLocationManager = [[CLLocationManager alloc] init];
    [newLocationManager setDesiredAccuracy:kCLLocationAccuracyBest];
    [newLocationManager setDistanceFilter:kCLDistanceFilterNone];
    [self setLocationManager:newLocationManager];


[[self locationManager] setDelegate:self];
[[self locationManager] startUpdatingLocation];
NSLog(@"Started updating Location");

}


- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

NSLog(@"Did update to location");
mStoreLocationButton.hidden=FALSE;
location=newLocation.coordinate;

MKCoordinateRegion region;
region.center=location;
MKCoordinateSpan span;
span.latitudeDelta=0.01;
span.longitudeDelta=0.01;
region.span=span;


[mapView setRegion:region animated:TRUE];


}
Run Code Online (Sandbox Code Playgroud)

我可以在第二种方法中设置断点,NSLog报告连续的位置更新,但由于某种原因,带有span的缩放不起作用.知道为什么吗?它有我的坐标和一切.在这一个上刮我的头.

iphone zoom mkmapview cllocationmanager ios

8
推荐指数
3
解决办法
2万
查看次数

如何删除数组中的一个重复值?

我有两个数组,我正在比较[Int]

let filter = strongAgainstArray.filter{weakAgainstArray.contains($0)}
Run Code Online (Sandbox Code Playgroud)

这将返回2个数组中的公共值数组.然后我想通过并从每个数组中删除这些值,我正在这样做

for item in filter {
    for var i = 0; i < strongAgainstArray.count; i += 1 {
        if item == strongAgainstArray[i] {
            strongAgainstArray.removeAtIndex(i)
            print("Removing a Strong against index \(item)")
        }
    }
    for var i = 0; i < weakAgainstArray.count; i += 1 {
        if item == weakAgainstArray[i] {
            weakAgainstArray.removeAtIndex(i)
            print("Removing a Weak against index \(item)")
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这工作正常,但我们可以说我的一个数组包含两个条目12作为示例.我如何只删除其中一个?目前,所有条目12都被完全删除.

编辑

我现在正在比较我的两个数组

let commonValues = Array(Set(strongAgainstArray).intersect(weakAgainstArray))

然后是commonValues每个数组中的那些

cleanStrongAgainstArray = …
Run Code Online (Sandbox Code Playgroud)

ios swift

0
推荐指数
1
解决办法
76
查看次数

标签 统计

ios ×2

cllocationmanager ×1

iphone ×1

mkmapview ×1

swift ×1

zoom ×1