zoukankan      html  css  js  c++  java
  • Whereami: CLLocationManager not calling delegate

    用的教程是Big Nerd Ranch 3th .

    whereami 的例子,使用CLLocationManager,书中的代码敲进去,但是没有NSLog location 信息,后来搜了下

    http://forums.bignerdranch.com/viewtopic.php?f=216&t=4514a  as responsed by  Basilornis

    The solution is twofold. If you are using Xcode5 you are using a storyboard. This does not call initWithNib. In order to get code execution going in whereAmI, you must replace that section with the following:

    原来Xcode5 用的是storyboard not Nib, 所以没有反应,注意拼写啊,分清楚 location ///locaitons , 最后问题解决。

     1 #import "WhereamiViewController.h"
     2 
     3 @implementation WhereamiViewController
     4 
     5 - (id)initWithCoder:(NSCoder *)aDecoder
     6 {
     7     self = [super initWithCoder:(NSCoder *)aDecoder];
     8     
     9     if (self) {
    10         // Create location manager object
    11         locationManager = [[CLLocationManager alloc] init];
    12         
    13         [locationManager setDelegate:self];
    14         
    15         // And we want it to be as accurate as possible
    16         [locationManager setDesiredAccuracy: kCLLocationAccuracyBest];
    17         
    18         // Test our manager to start looking for its location
    19         [locationManager startUpdatingLocation];
    20         
    21     }
    22     return self;
    23 }
    24 - (void) locationManager: (CLLocationManager *)manager
    25       didUpdateLocations:(NSArray *) locations
    26 
    27 {
    28     NSLog(@"%@", [locations lastObject]);
    29 }
    30 
    31 - (void)locationManager: (CLLocationManager *)manager
    32 didFailWithError:(NSError *)error
    33 {
    34     NSLog(@"Could not find location: %@", error);
    35 }
    36 @end
    View Code
  • 相关阅读:
    修改linux资源限制
    Windows 建立链接
    Java & ant环境变量配置
    Linux 配置IP
    Spring-MVC 访问静态资源
    Maven 安装与配置
    OIM同步OID(OID-Connector 9.0.4.12)
    Connector|OIM向IBM TDS推送账号(LDAP3)
    TopFreeTheme精选免费模板【20130704】
    30+简约和平铺的WordPress复古主题
  • 原文地址:https://www.cnblogs.com/sokeyer/p/3731851.html
Copyright © 2011-2022 走看看