那是时刻升级要升级的老三方库了,需要做如下2手续

自打苹果店以11月17如泣如诉开升级的话,官方显示iOS8已经起46%的份额,微信,支付宝,知乎和讯等为曾经包容iOS8,对于开发者来说,兼容iOS8
也是肯定的事务。上边说几接触自己在兼容iOS8时,发现的几触及问题。

算2经纬度之间的去(单位米)

<pre><code>
+(double)distanceBetweenOrderBy:(double)lat1 :(double)lat2 :(double)lng1
:(double)lng2
{
CLLocation* curLocation = [[CLLocation alloc] initWithLatitude:lat1
longitude:lng1];
CLLocation* otherLocation = [[CLLocation alloc]
initWithLatitude:lat2 longitude:lng2];
double distance = [curLocation distanceFromLocation:otherLocation];
return distance;
}
</code></pre>

1、SDK 里面的一些API不可能以iOS8下蛋以

假设,你的老项目在iOS8下运行,打开就闪退(iOS8在此之前没有问题),那么“恭喜你”,你中导致了,比如下面我遇上的,是盖原本本子的过人德地图引用了
iOS8
里面无法为此的api,要是您呢用接近之题目,那么是早晚升级需要提高的老三方库了。
<pre><code>2014-09-28 14:32:25.576
WoZaiXianChang[4505:140022] *** Terminating app due to uncaught
exception ‘NSInvalidArgumentException’, reason: ‘-[UIDevice
asUniqueDeviceIdentifier]: unrecognized selector sent to instance
0x7c020080’ </code></pre>

落当前手机所在地方

注意事项:需要考虑适配的问题,ios8下蛋稳定会砸,需要举办如下2步骤:
1、在被刷新[_locationManager
startUpdatingLocation];前添加[_locationManager
requestAlwaysAuthorization];(后台定位)或[_locationManager
requestWhenInUseAuthorization](前台定位)
2、在info.list中添加key
:NSLocationAlwaysUsageDescription或NSLocationWhenInUseUsageDescription

详尽的参阅代码
投入如上面文件
CoreLocation/CoreLocation.h
AddressBook/AddressBook.h
<pre><code>

2、iOS8 下边定位效能应用改变了

前版本的SDk是这般起步系统稳定的
<pre><code> // 判断定位操作是否被允许
if([CLLocationManager locationServicesEnabled]) {
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
[locationManager startUpdatingLocation];
}else {
//指示用户无法进行固化操作
}
</code></pre>假使在iOS8下用这么的方,你会意识不能稳定,这是盖iOS8下蛋补充加了新的计
<pre><code> /表示用应用程序期间 开启定位

  • (void)requestWhenInUseAuthorization
    //表示一向 开启定位
  • (void)requestAlwaysAuthorization </code></pre>

双面分别在,iOS7 开始,有再强硬的后台运行效果,假若 用
requestAlwaysAuthorization 方法,则意味着后台运行时为会师为此到一定
iOS8 下采纳系统定点如下:
<pre><code> // 判断定位操作是否让允许
if([CLLocationManager locationServicesEnabled]) {
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
//兼容iOS8定位
SEL requestSelector =
NSSelectorFromString(@”requestWhenInUseAuthorization”);
if ([CLLocationManager authorizationStatus] ==
kCLAuthorizationStatusNotDetermined &&
[locationManager respondsToSelector:requestSelector]) {
[locationManager requestWhenInUseAuthorization];
} else {
[locationManager startUpdatingLocation];
}
return YES;
}else {
//提醒用户不可以开展定点操作
}
return NO; </code></pre>
再者还需要补加新的方法,其他的都相同
<pre><code> – (void)locationManager:(CLLocationManager
*)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
if (status == kCLAuthorizationStatusAuthorizedWhenInUse) {
[locationManager startUpdatingLocation];
} else if (status == kCLAuthorizationStatusAuthorized) {
// iOS 7 will redundantly call this line.
[locationManager startUpdatingLocation];
} else if (status > kCLAuthorizationStatusNotDetermined) {
//…
[locationManager startUpdatingLocation];
}
} </code></pre>
除这多少个,你还得在 info.plist 里面上加新的键值,否则 也是不可能稳定的
<pre><code>//表示用应用程序期间 开启定位

  • (void)requestWhenInUseAuthorization 对应
    NSLocationWhenInUseUsageDescription key
    //表示一贯 开启定位
  • (void)requestAlwaysAuthorization 对应
    NSLocationAlwaysUsageDescription key</code></pre>

里头,NSLocationWhenInUseUsageDescription(或者NSLocationAlwaysUsageDescription)
对应的文会当首先浅呼吁用户同意定位的时出现,还有 设置 > 隐私 >
定位 > your app 里面为会合盼,比如下面就开启app时起的

图片 1

import “SystemMapkitViewController.h”

3、iOS8 下报公告的更改

这毫无多说,直接扣代码就知了,有好几得专注的凡,红色部分必须要加,不然就是能博取之token值,app
接受到的推送也是冷清的。
<pre><code>//注册音信通告
if (IOS8After) {
[[UIApplication sharedApplication]
registerForRemoteNotifications];
<span style=”color:#3333ff;”>[[UIApplication
sharedApplication]
registerUserNotificationSettings:[UIUserNotificationSettings
settingsForTypes:UIUserNotificationTypeBadge |
UIUserNotificationTypeSound | UIUserNotificationTypeAlert
categories:nil]];</span>
}
else {
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge)];
} </code></pre>

define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)

@interface SystemMapkitViewController
()<CLLocationManagerDelegate>

@property(nonatomic, strong) CLLocationManager *locationManager;

@end

@implementation SystemMapkitViewController

  • (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle
    *)nibBundleOrNil
    {
    self = [super initWithNibName:nibNameOrNil
    bundle:nibBundleOrNil];
    if (self) {
    // Custom initialization
    }
    return self;
    }

  • (void)viewDidLoad
    {
    [super viewDidLoad];

    //定位服务管理对象初叶化
    _locationManager = [[CLLocationManager alloc] init];
    _locationManager.delegate = self;
    //设置精度
    精度越来越强要得到地点音信的频率即便进一步强,着便吧为设备更加耗电
    _locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    //设置移动更新地方的然则小去
    _locationManager.distanceFilter = 1000.0f;
    self.view.backgroundColor = [UIColor darkGrayColor];

}

-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];

//ios8下定位服务时效 需要如下处理
/*requestAlwaysAuthorization (for background location) or requestWhenInUseAuthorization (location only when foreground) call on CLLocationManager is needed before starting location updates.
 There also needs to be NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription key in Info.plist with a message to be displayed in the prompt. Adding these solved my problem.
 */
if(IS_OS_8_OR_LATER) {
    [_locationManager requestAlwaysAuthorization];
}
//开启刷新
[_locationManager startUpdatingLocation];

}

-(void)viewWillDisappear:(BOOL)animated
{
//关闭服务
[_locationManager stopUpdatingLocation];
}

//当设备到过滤距离时刷新
-(void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations
{
CLLocation *currentLocation = locations.lastObject;

//地理信息反编码
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *placemarks, NSError *error) {
    if (placemarks > 0) {
        CLPlacemark *placemark = placemarks[0];
        NSDictionary *addressDictionary = placemark.addressDictionary;
        NSString *stree = [addressDictionary objectForKey:(NSString*)kABPersonAddressStreetKey]; //街道信息
        stree = stree = nil ? @"": stree;
        NSString *city = [addressDictionary objectForKey:(NSString*)kABPersonAddressCityKey]; //城市
        city = city = nil ? @"": city;
        NSString *stateaddress = [addressDictionary objectForKey:(NSString*)kABPersonAddressStateKey]; //州,省
        stateaddress = stateaddress = nil ? @"": stateaddress;
        NSString *zip = [addressDictionary objectForKey:(NSString*)kABPersonAddressZIPKey]; //zip
        zip = zip = nil ? @"": zip;
        NSString *country = [addressDictionary objectForKey:(NSString*)kABPersonAddressCountryKey]; //国家
        country = country = nil ? @"": country;
        NSString *CountryCode = [addressDictionary objectForKey:(NSString*)kABPersonAddressCountryCodeKey]; //
        CountryCode = CountryCode = nil ? @"": CountryCode;
        NSLog(@"%@\n%@\n%@\n%@\n%@\n%@",stree, city, stateaddress, zip, country,CountryCode);

    }

}];

NSString *latitude = [NSString stringWithFormat:@"%3.f",currentLocation.coordinate.latitude]; //维度
NSString *longitude = [NSString stringWithFormat:@"3.5f",currentLocation.coordinate.longitude];//精度
NSString *altitude = [NSString stringWithFormat:@"3.5f",currentLocation.altitude]; //高度
NSLog(@"维度:%@\n精度:%@\n高度:%@\n",latitude,longitude, altitude);

}

//定位退步
-(void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error
{
NSLog(@”error:%@”,error.description);
}

  • (void)didReceiveMemoryWarning
    {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    }

@end

</code></pre>

4、iOS8 cell 层级的改动

而你像这么取cell 的row
的话语,这您而且使加个判断方法了,在iOS8下蛋cell的层级又转移了,基本上每升级一个版本,苹果还相会针对cell的构造举办调,在斯指出不要就此如此的形式取cell
的row,而是用性的方法保留 indexPath
<pre><code>NSUInteger curRow = 0;
if ([[MetaData getOSVersion] integerValue] == 7)
{
curRow = [(UITableView *)[[self superview] superview]
indexPathForCell:self].row;
}
else
{
curRow = [(UITableView *)[self superview]
indexPathForCell:self].row;
} </code></pre>

IOS利用高德导航实现科普寻找

在起初勾画往日先行准备生如下几件事:
先是起事:申请
高德导航Key
留意:你的主次名称以及bundle
identifier必须跟报名时登记的同等,不否会不可能向下进展
搜索库,点击下载。解压后获取AMapSearch基特.framework文件。
补偿加相关库文件:
libstdc.6++
QuartzCore
CoreLocation
SystemCOnfiguration
libz
OpenGLES
CoreTelePhony
Security
在 TARGETS->Build Settings->Other Linker Flags 中添加-ObjC
POI搜索介绍:

高德地图提供了相对级其余POI(Point of
Interesting,兴趣点)。在地图表明着,一个POI可代表一如既往栋大厦、一小商铺、一处于景点等等。

iOS
SDK包括3体系型的POI搜索:关键字搜索、周边找、指定区域搜索。不同品种的POI搜索,区别在构造之摸索参数。其中:
最重要字搜索:keywords(关键词)和 types(类型)必使那一个,searchType 为
AMapSearchType_PlaceKeyword。
广大找:keywords(关键词)和 types(类型)必使这多少个,还一定如
location(主题点坐标),searchType为AMapSearchType_PlaceAround。
指定区域搜索:keywords(关键词)和 types(类型)必使这一个,还必然如
polygon(多边形),searchType为AMapSearchType_PlacePolygon。
证:types为POI的品类,编码表下载地址:
http://lbs.amap.com/wp-content/uploads/2014/06/AMap\_Api\_Table.zip

详见代码如下:
<pre><code>

5、UIActionSheet and UIAlertView 的升级

于iOS8中间,官方提供了新的好像UIAlertController来替换UIActionSheet and
UIAlertView。
示范代码如下:
<pre><code>
UIAlertController* alert = [UIAlertController
alertControllerWithTitle:@”My Alert”
message:@”This is an alert.”
preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@”OK”
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];

[self presentViewController:alert animated:YES completion:nil];
</pre></code>
关于何以呢加是仿佛,本人臆度是跟iOS8新加的size
classes有关,目的是统一屏幕在依次尺寸各类方向上之显得。假若您当iOS 8
里面用UIActionSheet and UIAlertView
可能会晤并发部分分外想拿到之问题,提议在iOS 8 里面用UIAlertController,iOS
8 往日使用UIActionSheet and UIAlertView
立时是近日截止发现的 iOS8 兼容性问题,我们发现另外兼容性问题,一起谈谈哦
正文在csdn下边也暴发发表:http://blog.csdn.net/wangyangyangcc/article/details/39637787

import “GaodeMapKitViewController.h”

import <AMapSearchKit/AMapSearchAPI.h>

@interface GaodeMapKitViewController ()<AMapSearchDelegate>
{
AMapSearchAPI * _search;
}
@end

@implementation GaodeMapKitViewController

  • (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle
    *)nibBundleOrNil
    {
    self = [super initWithNibName:nibNameOrNil
    bundle:nibBundleOrNil];
    if (self) {
    // Custom initialization
    }
    return self;
    }

  • (void)viewDidLoad
    {
    [super viewDidLoad];

    //起始化检索对象
    _search = [[AMapSearchAPI alloc] initWithSearchKey:keyChain
    Delegate:self];

    //沟槽AMapPlaceSearchRequest 对象,配置关键字搜索参数
    AMapPlaceSearchRequest *poiRequest = [[AMapPlaceSearchRequest
    alloc] init];
    // poiRequest.searchType = AMapSearchType_PlaceKeyword;
    poiRequest.searchType = AMapSearchType_PlaceAround;
    //
    查询关键字,多单首要字用“|”分割,“空格”表示与,“双引号”表示不可分割
    // poiRequest.keywords = @”服装”;
    poiRequest.types = @[@”050102″,@”050117″,@”060411″];
    //注意: keywords和types必如那些,设置2单会冲,什么呢查看不交

    poiRequest.city = @[@”beijing”];
    poiRequest.requireExtension = YES;
    // poiRequest.radius = 100; //查询半径,单位:米 [default =
    3000]
    //设置基本点(史各庄)
    poiRequest.location = [AMapGeoPoint
    locationWithLatitude:40.10381112 longitude:116.29337311];
    //发起 POI 搜索
    [_search AMapPlaceSearch: poiRequest];
    }

//实现 POI 搜索对应之回调函数

  • (void)onPlaceSearchDone:(AMapPlaceSearchRequest *)request
    response:(AMapPlaceSearchResponse *)response
    {
    if(response.pois.count == 0) {
    return; }
    //处理搜索结果的到底记录数
    NSLog(@”记录数:%ld”,response.count);

    for (AMapPOI *p in response.pois) {
    //显示搜到之讳
    NSLog(@”%@”,p.name);

    }

}

  • (void)didReceiveMemoryWarning
    {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    }

@end
</code></pre>

下边让有档次被因故到的工具:
高德导航在线获取经纬度
下载 POI
分类编码表和市编码表。

上高德地图需要之网址:
高德参考API
表达:平日使用的定点,查找都出大概的例子

下载高德地图 iOS V2.4.X
版本的支付指南。

相关文章