Permalink
Browse files

changed the callout button button action to fire on the UIControlEven…

…tTouchDown event instead of UIControlEventTouchUpInside for older devices which seemed to be delayed in responding
  • Loading branch information...
1 parent 54e5d42 commit fda87ca0048f4b24c751b2d9d5c3434de5b3fd9e @btjones btjones committed Sep 4, 2011
@@ -32,5 +32,6 @@ typedef enum {
- (void)setFilters:(NSArray *)filters forFilterType:(FilterType)filterType;
- (void)startActivity;
- (void)stopActivity;
++ (BOOL)isNewHardware;
@end
@@ -162,4 +162,28 @@ - (void)stopActivity {
}
}
+#pragma mark - device methods
+
+//determines if this is a newer device based on the screen scale and if this is an ipad or not
+//UIScreen scale is only available in ios 4+ and will be larger than 1.0 for retina devices
++ (BOOL)isNewHardware {
+
+ //is this an ipad
+ //not using UI_USER_INTERFACE_IDIOM because that returns NO when running an iPhone interface on an iPad
+ if (NSClassFromString(@"UIPopoverController")) {
+ return YES;
+ }
+
+ //is this a retina display device
+ UIScreen *screen = [UIScreen mainScreen];
+ if ([screen respondsToSelector:@selector(scale)]) {
+ if (screen.scale > 1.0f) {
+ return YES;
+ }
+ }
+
+ //default to no
+ return NO;
+}
+
@end
@@ -398,13 +398,22 @@ - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *
//create the callout if it doesn't exist yet
if (!self.callout) {
+
+ //setup the callout view
CalloutAnnotationView *aCallout = [[CalloutAnnotationView alloc] initWithCoordinate:[(ArtAnnotation *)view.annotation coordinate] frame:CGRectMake(0.0f, 0.0f, 320.0f, 335.0f)];
- [aCallout setMapView:self.mapView.map];
- [aCallout.button addTarget:self action:@selector(calloutTapped) forControlEvents:UIControlEventTouchUpInside];
+ [aCallout setMapView:self.mapView.map];
[self setCallout:aCallout];
[aCallout release];
+
+ //newer devices respond bettern to the preferred UIControlEventTouchUpInside
+ //older devices seem delayed so use UIControlEventTouchDown
+ [aCallout.button addTarget:self action:@selector(calloutTapped) forControlEvents:([Utilities isNewHardware]) ? UIControlEventTouchUpInside : UIControlEventTouchDown];
+
} else {
+
+ //update the coordinate
[self.callout setCoordinate:[(ArtAnnotation *)view.annotation coordinate]];
+
}
//first move the annotation, set the new art, then add it to the map

0 comments on commit fda87ca

Please sign in to comment.