• ios8中修改的 推送和地图


    ios8之前 注册通知的方法是

       
        [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeBadge];

    ios8 注册这样写

        UIUserNotificationSettings *setting = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil];
        [application registerUserNotificationSettings:setting];

    有关CLLocationManager

        locationManager = [[CLLocationManager alloc] init];
        locationManager.delegate = self;
        [locationManager startUpdatingLocation];

    ios8之后添加了    [locationManager requestAlwaysAuthorization];

    其他的内容没什么变化 info.plist中 添加两个字段NSLocationWhenInUseUsageDescription和NSLocationAlwaysUsageDescription

     定位以后的回调方法如下

    -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations

    在这个方法里可以拿到经纬度 控制定位结束 可以地理反编码 拿到当前的位置信息

     CLGeocoder *geocoder = [[CLGeocoder alloc] init];
        [geocoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error) {
            for (CLPlacemark *place in placemarks) {
                
                NSLog(@"name,%@",place.name); // 位置
                [manager stopUpdatingLocation];
    
            }
        }];
    //有关 这个CLPlacemark 可以点进去查看 
    
    /*包括街道信息也可以拿到
    @property (nonatomic, readonly, copy) NSDictionary *addressDictionary;
    
    // address dictionary properties
    @property (nonatomic, readonly, copy) NSString *name; // eg. Apple Inc.
    @property (nonatomic, readonly, copy) NSString *thoroughfare; // street address, eg. 1 Infinite Loop
    @property (nonatomic, readonly, copy) NSString *subThoroughfare; // eg. 1
    @property (nonatomic, readonly, copy) NSString *locality; // city, eg. Cupertino
    @property (nonatomic, readonly, copy) NSString *subLocality; // neighborhood, common name, eg. Mission District
    @property (nonatomic, readonly, copy) NSString *administrativeArea; // state, eg. CA
    @property (nonatomic, readonly, copy) NSString *subAdministrativeArea; // county, eg. Santa Clara
    @property (nonatomic, readonly, copy) NSString *postalCode; // zip code, eg. 95014
    @property (nonatomic, readonly, copy) NSString *ISOcountryCode; // eg. US
    @property (nonatomic, readonly, copy) NSString *country; // eg. United States
    @property (nonatomic, readonly, copy) NSString *inlandWater; // eg. Lake Tahoe
    @property (nonatomic, readonly, copy) NSString *ocean; // eg. Pacific Ocean
    @property (nonatomic, readonly, copy) NSArray *areasOfInterest; // eg. Golden Gate Park
    */
  • 相关阅读:
    Redis-高级教程-Java 使用
    Redis-高级教程-分区
    Redis-高级教程-管道技术
    Redis-高级教程-客户端连接
    Redis-高级教程-性能测试
    Redis-高级教程-安全
    Redis-高级教程-数据备份与恢复
    Redis-命令-Stream
    NG-ZORRO + Angular11增加自定义全局样式,不影响其他页面全局样式,仅作用于当前页面
    VUE上传表格文件发送后端,后端解析以及上传文件,前端进行解析的实现方法
  • 原文地址:https://www.cnblogs.com/machealking/p/4635541.html
Copyright © 2020-2023  润新知