美文网首页
iOS系统定位与不锁屏

iOS系统定位与不锁屏

作者: 蜗牛锅 | 来源:发表于2017-06-06 17:58 被阅读118次

// 定位的头文件

import "CCLocationManager.h"

需要遵守的代理 <CLLocationManagerDelegate>

[UIApplication sharedApplication].idleTimerDisabled=YES;不自动锁屏
[UIApplication sharedApplication].idleTimerDisabled=NO;自动锁屏

    CLLocationManager *locationmanager = [[CLLocationManager alloc] init];
    [locationmanager requestAlwaysAuthorization];
    [locationmanager requestWhenInUseAuthorization];
    locationmanager.delegate = self;
   // 2.0 获得经纬度
    [[CCLocationManager shareLocation] getLocationCoordinate:^(CLLocationCoordinate2D locationCorrrdinate) {
        
        NSString *lngStr  = [NSString stringWithFormat:@"%f", locationCorrrdinate.longitude];
        NSString *latStr = [NSString stringWithFormat:@"%f", locationCorrrdinate.latitude];
        
        if (lngStr.length > 0 && latStr.length > 0) {
            
            [NSUSERDEFAULTS setValue:lngStr forKey:kLongitude];
            [NSUSERDEFAULTS setValue:latStr forKey:kLatitude];
            
            [self getLocationForNetWithLng:lngStr AndLat:latStr];
            
        }
        
    }];

相关文章

网友评论

      本文标题:iOS系统定位与不锁屏

      本文链接:https://www.haomeiwen.com/subject/pxknfxtx.html