高德地图作业一

#pragma mark -添加选择工具条

/**

 *  定位用户位置的模式:

     MAUserTrackingModeNone              = 0,    // 不追踪用户的location更新

     MAUserTrackingModeFollow            = 1,    // 追踪用户的location更新

     MAUserTrackingModeFollowWithHeading = 2     // 追踪用户的locationheading更新

 

 */

- (void)initToolBar{

    

    

    UISegmentedControl *searchTypeSegCtl = [[UISegmentedControl alloc] initWithItems:

                                            [NSArray arrayWithObjects:

                                             @"默认",

                                             @"位置",

                                             @"多方位",

                                             nil]];

    searchTypeSegCtl.selectedSegmentIndex  = _mapView.userTrackingMode;

    searchTypeSegCtl.frame = CGRectMake(200, CGRectGetHeight(_mapView.bounds) - 40, 160, 30);

    [searchTypeSegCtl addTarget:self action:@selector(userTrackingModeType:) forControlEvents:UIControlEventValueChanged];

    

    

    [_mapView addSubview:searchTypeSegCtl];

}

 

主要,该方法要在viewDidLoad里面实现,再写下如下方法监听按钮变化

 

- (void)userTrackingModeType:(UISegmentedControl *)segmentedControl

{

    _mapView.userTrackingMode = (long)segmentedControl.selectedSegmentIndex;

    

    NSLog(@"_mapView.userTrackingMode:%ld",(long)_mapView.userTrackingMode);

    

}

 

完。

posted on 2016-01-02 13:19  十一点前要睡觉的小寒  阅读(364)  评论(0编辑  收藏  举报