zoukankan      html  css  js  c++  java
  • iOS 8 定位失败问题

    首先plist定义两个string:
     NSLocationWhenInUseUsageDescription
    NSLocationAlwaysUsageDescription
    然后调用
    [self.locationManager requestWhenInUseAuthorization]
    或者
    [self.locationManager requestAlwaysAuthorization]
    例如
    #import "ViewController.h"
    @import CoreLocation;
     
    @interface ViewController ()
    @property (strong, nonatomic) CLLocationManager *locationManager;
    @end
     
    @implementation ViewController
     
    - (void)viewDidLoad
    {
        [super viewDidLoad];
     
        // ** Don't forget to add NSLocationWhenInUseUsageDescription in MyApp-Info.plist and give it a string
     
        self.locationManager = [[CLLocationManager alloc] init];
        self.locationManager.delegate = self;
        // Check for iOS 8. Without this guard the code will crash with "unknown selector" on iOS 7.
        if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
            [self.locationManager requestWhenInUseAuthorization];
        }
        [self.locationManager startUpdatingLocation];
    }
     
    // Location Manager Delegate Methods    
    - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
    {
        NSLog(@"%@", [locations lastObject]);
    }
     
    @end
  • 相关阅读:
    统计学基础
    ip地址分类
    OSI七层协议与TCP/IP模型、三次握手与四次挥手
    计算机编码
    [HNOI2008]Cards
    P4309 [TJOI2013]最长上升子序列
    P3794 签到题IV
    P2605 [ZJOI2010]基站选址
    UVA10791
    P3825 [NOI2017]游戏
  • 原文地址:https://www.cnblogs.com/isItOk/p/4875545.html
Copyright © 2011-2022 走看看