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
  • 相关阅读:
    FSCapture 取色工具(绿色版 )
    Java EE.JavaBean
    Java EE.JSP.内置对象
    Java EE.JSP.动作组件
    Java EE.JSP.指令
    Java EE.JSP.脚本
    21、多态与多态性、内置方法、反射、异常处理
    20、继承的应用、super、组合
    19、property、绑定方法(classmethod、staticmethod)、继承
    18、类
  • 原文地址:https://www.cnblogs.com/sokeyer/p/3731851.html
Copyright © 2011-2022 走看看