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
  • 相关阅读:
    POJ 2752 KMP中next数组的理解
    KMP详解
    HDU 3221 矩阵快速幂+欧拉函数+降幂公式降幂
    POJ 3220 位运算+搜索
    反素数深度分析
    POJ 2886 线段树单点更新
    求反素数的方法
    CV第八课 GPU/CPU
    49. 字母异位词分组
    48. 旋转图像
  • 原文地址:https://www.cnblogs.com/sokeyer/p/3731851.html
Copyright © 2011-2022 走看看