p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px 'Lucida Grande'; color: #929292}
TapDetectingWindow.h
//
// plist>
// NBFisheryiPad
//
// Created by shiqyn on 11-6-16.
// Copyright 2011 Stongsoft. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol TapDetectingWindowDelegate<NSObject>
- (void)userDidTapObserveView:(id)tapPoint;
@end
@interface TapDetectingWindow : UIWindow {
UIView *viewToObserve;
id <TapDetectingWindowDelegate> controllerThatObserves;
}
@property (nonatomic, retain) UIView* viewToObserve;
@property (nonatomic, assign) id <TapDetectingWindowDelegate> controllerThatObserves;
@end
TapDetectingWindow.m
//
// plist>
// NBFisheryiPad
//
// Created by shiqyn on 11-6-16.
// Copyright 2011 Stongsoft. All rights reserved.
//
#import "TapDetectingWindow.h"
@implementation TapDetectingWindow
@synthesize viewToObserve;
@synthesize controllerThatObserves;
- (id)initWithViewToObserver:(UIView *)view andDelegate:(id)delegate {
if(self == [super init]) {
self.viewToObserve = view;
self.controllerThatObserves = delegate;
}
return self;
}
- (void)dealloc {
[viewToObserve release];
[super dealloc];
}
- (void)forwardTap:(id)touch
{
[controllerThatObserves userDidTapObserveView:touch];
}
- (void)sendEvent:(UIEvent *)event
{
[super sendEvent:event];
if (viewToObserve == nil || controllerThatObserves == nil)
return;
NSSet *touches = [event allTouches];
if (touches.count != 1)
return;
UITouch *touch = touches.anyObject;
if (touch.phase != UITouchPhaseEnded)
return;
if ([touch.view isDescendantOfView:viewToObserve] == NO)
return;
CGPoint tapPoint = [touch locationInView:viewToObserve];
NSArray *pointArray = [NSArray arrayWithObjects:[NSString stringWithFormat:@"%f", tapPoint.x],
[NSString stringWithFormat:@"%f", tapPoint.y], nil];
if (touch.tapCount == 1)
{
[self performSelector:@selector(forwardTap:) withObject:pointArray afterDelay:0];
}
else if (touch.tapCount > 1)
{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(forwardTap:) object:pointArray];
}
}
@end
用法:
1.双击MainWindow.xib, 弹出的Window,按control+2,弹出的window attributes窗口中 将class identity设置成TapDetectingwindow.
2.在要使用TapDetectingwindow类中添加如下代码:
TapDetectingWindow* tapDetectWindow = ((TapDetectingWindow *)[[UIApplication sharedApplication].windows objectAtIndex:0]);
tapDetectWindow.viewToObserve = mapView;
tapDetectWindow.controllerThatObserves = self;
并实现delegate:
#pragma mark TapDetectingWindowDelegate
- (void)userDidTapObserveView:(id)tapPoint
{
DLog(@">>>userDidTapObserveView");
[self hideSearchRangeSlider];
}
分享到:
相关推荐
iPhone MKMAPView中根据gps坐标画路径,可以支持google map缩放
MKMapView自定义calloutView,完全自定义布局。。
TSClusterMapView, 用于iOS和OSX的动画集群 MKMapView TSClusterMapView - 带集群的MKMapView动画注释集群MKMapView子类基于 ADClusterMapView 。用法要运行示例项目,克隆 repo,然后从示例目录中运行 pod install ...
FlyoverKit:在 MKMapView 上实现 360° 俯视图.zip,360° flyover on a MKMapView
MKMapView在中国显示地图和卫星图存在位置上的偏差,因此很多时侯在定位跟踪的时候常常是卫星定位而标准地图显示,因此常发现位置点不居中显示,当然这个可以使用开启用户位置跟踪模式来进行定位。本DEMO也正是利用...
MTDirectionsKit, 在MKMapView之上,直接显示方向 为什么 MTDirectionsKit?为什么苹果没有为你提供直接显示在MKMapView之上的方法,强迫你在中 switch,只是为了引导你的用户在某个地方。 我们也是这样,所以我们...
NULL 博文链接:https://chinaxxren.iteye.com/blog/1150309
在一个MKMapView上360° 展示一个高架公路
系统地图MKMapView的定位及导航 UISearchController模糊查询点击每个UITableViewCell 在地图上显示大头针 ,点击大头针的右边到这里去,调用系统导航,模糊查询数据源来自百度api 写的有点简单,有点乱
最近使用MKMapView,发现有内存泄露。经查发现属iOS系统 bug,详情我发表的文章:http://blog.csdn.net/rigel_xu/article/details/52146774
自定义 callout! 通过手势 添加多个气泡
8.0以后的GPS定位问题,添加的一些配置信息
在 MKMapView 中实现地址选择和导航功能。具有以下特点: 1:支持ios5~7 2:自定义MKAnnotationView 3:支持第三方导航功能、包括高德、百度、苹果、谷歌,以及绘制路线,类似微信发生地址 4:支持滑动地图,选择...
kingpin, 在MKMapView的地图注释集群库中, kingpin一种面向iOS的MKAnnotation集群库。 特性使用 2-d 树,以实现最大性能。无需子类化,使库易于与现有项目集成。安装 CocoaPods要在 Podfile 中获得稳定的发行版,请...
从 MKMapView 取出来的经纬度去 Google Maps API 做逆地址解析终于对了。去百度地图API做逆地址解析,依旧是错的! 从上面两处取的经纬度放到百度地图上显示都是错的!错的!的! 分为 地球坐标,火星坐标(iOS...
ios 地图开发sample code,画路线图。
作者s3lvin,源码DXCustomCallout-ObjC,DXCustomCallout-ObjC 是一个在 MKMapview 上实现 CustomCallouts 的简单方法。
RxMKMapView是MKMapView(MapKit) delegate的包装器,提供了React式委托代理以及可绑定的注释接口,以动态更改地图的“数据源”。 安装 RxMKMapView可通过。 要安装它,只需将以下行添加到您的Podfile中: pod ...
FlyoverKit您可以在零维护的情况下在MKMapView上呈现令人惊叹的360°飞越视图,同时保持完整的配置可能性。 FlyoverKit的生成的核心使您的方式通过三维360°天桥的MapView请求用户位置的服务。 例 示例应用程序是...
省会城市 MKMapView,MKAnnotation,MKPinAnnotationView,CLLocationCoordinate2D 在您了解MKMapView和注解的同时,向用户介绍地理。