zoukankan      html  css  js  c++  java
  • 简单理解MapView 以及 设置 MKAnnotationView

    MKMapView  相当于一个容器 。可以展示  MKAnnotationView..

    要使用它需要设置 数据源代理  

        _mapView.delegate = self;

     它的数据源对象就是 

    符合   MKAnnotation   协议的对象 

    包含

    @protocol MKAnnotation <NSObject>
    
    // Center latitude and longitude of the annotion view.
    // The implementation of this property must be KVO compliant.
    @property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
    
    @optional
    
    // Title and subtitle for use by selection UI.
    @property (nonatomic, readonly, copy) NSString *title;
    @property (nonatomic, readonly, copy) NSString *subtitle;
    
    // Called as a result of dragging an annotation view.
    - (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate NS_AVAILABLE(10_9, 4_0);
    
    @end

    这里不得不关联下 最常用的tableView 控件 

    它也需要数据源   和 代理 

    需要把数据源  加载到 tableViewCell 上 显示

    对比mapView ,它的数据源是  (id<MKAnnotation>)annotation

    - (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id<MKAnnotation>)annotation {

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath...

    对比下  是不是很相识 。。

    同样的还有 uipickerView

    下面实现自定义  MKAnnotationView 跟自定义UITabelViewcell  差不多

    http://www.codigator.com/tutorials/advanced-mapkit-tutorial-for-ios-custom-callout/

    实现  不点击annotation 也能显示calloutview 

    添加 代理方法

    - (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views {
            
        for (MKAnnotationView *annoView in views) {
                    
            MKAnnotation *anno = annoView.annotation;
                    [mv selectAnnotation:anno animated:YES]; 
        }
    }
  • 相关阅读:
    FxCopCmd.exe 返回错误代码 65[翻译]
    关于VS2005安装项目制作的三个参考文章链接
    Windows服务开发的四个小经验
    ThreadLocal详解
    java修饰符详解
    聚合、组合、关联、继承之间的区别【转】
    centos单用户模式修改ROOT密码
    vim的配置
    spring注解详解
    centOS修改文本界面分辨率
  • 原文地址:https://www.cnblogs.com/DamonTang/p/3684707.html
Copyright © 2011-2022 走看看