iOS開發之地圖代理不起作用(提示vImage decode failed, falling back to CG path.)

來源:互聯網
上載者:User

標籤:arc   地圖   代理無效   locationmanager   

項目中用到了地圖相關的東西,就把以前的demo搬了出來,結果發現直接運行之前的demo沒有問題,在xcode5下建立項目再把代碼粘貼過來就會提示

May  5 11:36:21 infomedia-iPod-touch TestLocation[1465] <Error>: CGBitmapContextCreate: unsupported parameter combination: 5 integer bits/component; 16 bits/pixel; 3-component color space; kCGImageAlphaNoneSkipLast; 512 bytes/row.May  5 11:36:21 infomedia-iPod-touch TestLocation[1465] <Error>: CGBitmapContextCreate: unsupported parameter combination: 5 integer bits/component; 16 bits/pixel; 3-component color space; kCGImageAlphaNoneSkipLast; 512 bytes/row.2014-05-05 11:36:21.974 TestLocation[1465:8b03] vImage decode failed, falling back to CG path.2014-05-05 11:36:21.969 TestLocation[1465:9003] vImage decode failed, falling back to CG path.May  5 11:36:22 infomedia-iPod-touch TestLocation[1465] <Error>: CGBitmapContextCreate: unsupported parameter combination: 5 integer bits/component; 16 bits/pixel; 3-component color space; kCGImageAlphaNoneSkipLast; 512 bytes/row.2014-05-05 11:36:22.653 TestLocation[1465:a003] vImage decode failed, falling back to CG path.May  5 11:36:22 infomedia-iPod-touch TestLocation[1465] <Error>: CGBitmapContextCreate: unsupported parameter combination: 5 integer bits/component; 16 bits/pixel; 3-component color space; kCGImageAlphaNoneSkipLast; 512 bytes/row.2014-05-05 11:36:22.691 TestLocation[1465:9503] vImage decode failed, falling back to CG path.May  5 11:36:22 infomedia-iPod-touch TestLocation[1465] <Error>: CGBitmapContextCreate: unsupported parameter combination: 5 integer bits/component; 16 bits/pixel; 3-component color space; kCGImageAlphaNoneSkipLast; 512 bytes/row.2014-05-05 11:36:22.711 TestLocation[1465:890b] vImage decode failed, falling back to CG path.May  5 11:36:22 infomedia-iPod-touch TestLocation[1465] <Error>: CGBitmapContextCreate: unsupported parameter combination: 5 integer bits/component; 16 bits/pixel; 3-component color space; kCGImageAlphaNoneSkipLast; 512 bytes/row.2014-05-05 11:36:22.725 TestLocation[1465:9003] vImage decode failed, falling back to CG path.May  5 11:36:22 infomedia-iPod-touch TestLocation[1465] <Error>: CGBitmapContextCreate: unsupported parameter combination: 5 integer bits/component; 16 bits/pixel; 3-component color space; kCGImageAlphaNoneSkipLast; 512 bytes/row.2014-05-05 11:36:22.733 TestLocation[1465:9b03] vImage decode failed, falling back to CG path.May  5 11:36:22 infomedia-iPod-touch TestLocation[1465] <Error>: CGBitmapContextCreate: unsupported parameter combination: 5 integer bits/component; 16 bits/pixel; 3-component color space; kCGImageAlphaNoneSkipLast; 512 bytes/row.2014-05-05 11:36:22.736 TestLocation[1465:8b03] vImage decode failed, falling back to CG path.May  5 11:36:22 infomedia-iPod-touch TestLocation[1465] <Error>: CGBitmapContextCreate: unsupported parameter combination: 5 integer bits/component; 16 bits/pixel; 3-component color space; kCGImageAlphaNoneSkipLast; 512 bytes/row.2014-05-05 11:36:22.777 TestLocation[1465:9207] vImage decode failed, falling back to CG path.

檢查了很多遍,代碼一模一樣,就是代理方法不執行,到網上搜了好多資料,沒有解決。最後想到在xcode5和xcode4.6下開發的差異,估計是arc搗的鬼,然後把arc改為NO,結果就正常運行了。順便把代碼貼出來……


工具:xcode5.0

1.建立一個single view application ,匯入map kit和core location庫,將arc改為NO

2.ViewController.h檔案

#import <UIKit/UIKit.h>#import <MapKit/MapKit.h>#import <CoreLocation/CoreLocation.h>@interface ViewController : UIViewController<CLLocationManagerDelegate> {    MKMapView *_mapView;    UILabel *_showLabel;}@end

ViewController.m檔案

#import "ViewController.h"#import "MapAddress.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad{    [super viewDidLoad];        CLLocationManager* manager = [[CLLocationManager alloc] init];    //定位的精確度    manager.desiredAccuracy = kCLLocationAccuracyBest;    //定位距離    manager.distanceFilter = 1;    manager.delegate = self;    //開始定位    [manager startUpdatingLocation];        //地圖    _mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];    _mapView.showsUserLocation = YES;    [self.view addSubview:_mapView];}//定位成功- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{    //當前的位置    CLLocation* newLocation = [locations lastObject];    NSString* str = [MapAddress getGoogleAddress:newLocation];    NSLog(@"%@",str);        //停止定位    //[manager stopUpdatingLocation];        //地圖顯示    //定位後的經緯度    CLLocationCoordinate2D coordinate = newLocation.coordinate;    //縮放比例    MKCoordinateSpan span = MKCoordinateSpanMake(0.1, 0.1);    //確定要顯示的地區    MKCoordinateRegion region = MKCoordinateRegionMake(coordinate, span);    //讓地圖顯示這個地區    [_mapView setRegion:region animated:YES];}//定位失敗- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{    NSLog(@"定位失敗");}@end

3.MapAddress.h檔案

#import <Foundation/Foundation.h>#import <CoreLocation/CoreLocation.h>@interface MapAddress : NSObject+ (NSString *) getBaiduAddress:(CLLocation *)location;+ (NSString *) getGoogleAddress:(CLLocation *)location;@end

MapAddress.m檔案

#import "MapAddress.h"@implementation MapAddress+ (NSString *) getBaiduAddress:(CLLocation *)location {    double latitude = location.coordinate.latitude;    double longtitude = location.coordinate.longitude;    NSString *urlstr = [NSString stringWithFormat:                        @"http://api.map.baidu.com/geocoder?output=json&location=%f,%f&key=dc40f705157725fc98f1fee6a15b6e60",                        latitude, longtitude];    NSURL *url = [NSURL URLWithString:urlstr];    NSString *s = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];    return s;}+ (NSString *) getGoogleAddress:(CLLocation *)location {    NSString *urlstr = [NSString stringWithFormat:                        @"http://maps.google.com/maps/api/geocode/json?latlng=%f,%f&language=zh-CN&sensor=false",                        location.coordinate.latitude, location.coordinate.longitude];    NSLog(@"%@", urlstr);    NSURL *url = [NSURL URLWithString:urlstr];    NSString *s = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];    return s;}@end


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.