iOS系统定位与不锁屏

// 定位的头文件

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];
            
        }
        
    }];

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容