貌似掉入iOS 7的坑了

leezhm 发布于 2013年10月15日
无人欣赏。

新项目,用Xcode5基于iOS 7开发,今天发现貌似掉入一个地图API的坑了。 -(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation 根本不调用(注,已经设置了self.mapViewer.showsUserLocation = YES

然后会出现如下错误

 2013-10-15 22:34:18.754 FloweryFairy-iOS7[3879:a0b] Cannot find executable for CFBundle 0x9dc8540 </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/System/Library/AccessibilityBundles/GeoServices.axbundle> (not loaded)

Oct 15 22:34:19 Hseecoms-iMac.local FloweryFairy-iOS7[3879] <Error>: CGBitmapContextCreate: unsupported parameter combination: 5 integer bits/component; 16 bits/pixel; 3-component color space; kCGImageAlphaNoneSkipLast; 512 bytes/row.

 2013-10-15 22:34:19.164 FloweryFairy-iOS7[3879:9303] vImage decode failed, falling back to CG path.

没办法,把之前基于iOS 6的例子,编译测试。发现如果是iOS 6没有任何问题,如果设置为iOS 7就出现同样的问题。

网络搜索发现 下面两个帖子遇到了同样的问题!

http://www.cocoachina.com/bbs/read.php?tid=159223

http://www.cocoachina.com/bbs/m/read.php?tid=159477#read

问问这里有人遇到了这个问题么,Stackoverflow上暂时没看到别人问这个问题的。@tinyfool 帮忙转转。

共15条回复
leezhm 回复于 2013年10月15日

有人说是这个API过期了,但是我在文档中没看到说过期啊!

tinyfool 回复于 2013年10月15日

-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation像是那个代码里面有问题,而不是这个东西不被调用了,你把代码贴出来看看。

leezhm 回复于 2013年10月15日
@interface XixiMainViewController ()

@property (strong, nonatomic) IBOutlet MKMapView *mapViewer;

@property (nonatomic, strong) CLLocationManager * locationManager;

@end

@implementation XixiMainViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    UIColor * background = [UIColor colorWithRed:0.43137f green:0.8f blue:0.94118 alpha:1.0f];
    [self.view setBackgroundColor:background];

    // init the map kit view
    self.mapViewer.autoresizingMask = (UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
    self.mapViewer.delegate = self;

    //
    self.mapViewer.showsUserLocation = YES;
    self.mapViewer.zoomEnabled = YES;
    self.mapViewer.scrollEnabled = YES;


    // check the whether the location services is enable
    if ([CLLocationManager locationServicesEnabled]) {

        // enable
        self.locationManager = [CLLocationManager new];
        self.locationManager.delegate = self;

        // set the location accuracy
        [self.locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
        [self.locationManager startUpdatingLocation];
    } else {

        // show the alert window
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"警告" message:@"为了获得更好的体验,请开启GPS定位服务!"
                                                       delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];
    } 
}

-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    // log current position
    NSLog(@"Current Position(%f, %f)", userLocation.coordinate.latitude, userLocation.coordinate.longitude);

    MKCoordinateRegion currentRegion = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, 500, 500);
    [self.mapViewer setRegion:currentRegion animated:YES];
}
leezhm 回复于 2013年10月15日

2楼 @tinyfool 代码贴的太难受了!在来编辑

tinyfool 回复于 2013年10月15日

4楼 @leezhm 有带预览的编辑器你们都贴不好代码。。。。

Markdown多简单啊

tinyfool 回复于 2013年10月15日

@sycx 看看

leezhm 回复于 2013年10月15日

5楼 @tinyfool 论坛支持么,貌似不支持啊,我只看到单行代码的

tinyfool 回复于 2013年10月15日 | 更新于 2013年10月16日

7楼 @leezhm 工具栏,101010就是贴代码的意思……

先把一堆代码贴进来,然后选中,然后点击那个按钮……

leezhm 回复于 2013年10月15日

8楼 @tinyfool 好吧,我错了。 我发帖的时候默认用了单行代码 然后习惯于markdown的多行代码三点)发现不支持。后来的确使用了101010这个的,不过我是先点击这个,让出现enter code here,当我把代码弄进去,发现还是不对的。现在根据你的提示,先贴代码,然后在点击101010,成功了!

sycx 回复于 2013年10月15日

我覺得你應該檢查下self.mapViewer是不是nil

tinyfool 回复于 2013年10月16日

9楼 @leezhm 我大概实现了你的代码,发现没有问题,这个回调函数会被调用的。

你说的那些错误信息,应该是框架本身的错误信息,跟着回调函数没有什么关系,不影响使用,我也遇到了,即使没有didUpdateUserLocation这个函数一样的。

我现在比较怀疑的是你的Mapview,是不是设置了showsUserLocation属性??文档里面写了,不设置这个收不到信息的。

leezhm 回复于 2013年10月16日

11楼 @tinyfool @sycxl 两位老师,我应该是还原了Bug的。

我用iMAC的Sharing来Share了一个WIFI,然后iPhone 5(iOS 7)连上WIFI 在此种情况下,不能定位,也当然不调用-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation

但是我关掉iPhone上的WIFI,连上3G网络,马上可以定位。

昨晚回家的路上,再次打开,发现能够定位,所以今天来做了这个实验。

BTW:@tingfool 我设置了showUserLocation属性,也看到了那个文档说明,需要check才能够定位。

leezhm 回复于 2013年10月16日

还有,一样的程序,一样的环境在iOS 6.1的版本上没有任何问题

tinyfool 回复于 2013年10月16日

12楼 @leezhm 看不懂你的意思,能定位不就对了么?

leezhm 回复于 2013年10月16日

@tingfool 但是为啥在连接WIFI的时候,就不能定位了呢?

本帖有15个回复,因为您没有注册或者登录本站,所以,只能看到本帖的10条回复。如果想看到全部回复,请注册或者登录本站。

登录 或者 注册
相关帖子

[顶 楼]
|
|
[底 楼]
|
|
[首 页]