-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-12582] iOS: Adding custom views in the pin #3887
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d1aef8e
[TIMOB-12582] Implementation of annotation with custom view
vishalduggal 7e79888
[TIMOB-12582] Hook the existing maps to the new annotation type
vishalduggal 9e22584
[TIMOB-12582] Ensure flags are cleared so we get a relayout signal
vishalduggal 7bf9821
[TIMOB-12582] Ensure that the customView is not interactable
vishalduggal adc70d6
[TIMOB-12582] Suppress clicks on refresh Annotation
vishalduggal 924103e
[TIMOB-12582] Update docs
vishalduggal eb67de6
[TIMOB-12582] Fixed Typo
vishalduggal File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Appcelerator Titanium Mobile | ||
* Copyright (c) 2013 by Appcelerator, Inc. All Rights Reserved. | ||
* Licensed under the terms of the Apache Public License | ||
* Please see the LICENSE included with this distribution for details. | ||
*/ | ||
#import "TiBase.h" | ||
|
||
#ifdef USE_TI_MAP | ||
|
||
#import <MapKit/MapKit.h> | ||
#import "TiMapView.h" | ||
#import "TiViewProxy.h" | ||
|
||
@interface TiMapCustomAnnotationView : MKAnnotationView<TiMapAnnotation> { | ||
@private | ||
NSString * lastHitName; | ||
TiViewProxy* theProxy; | ||
UIView* wrapperView; | ||
} | ||
|
||
- (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier map:(TiMapView*)map; | ||
- (NSString *)lastHitName; | ||
- (void)setProxy:(TiViewProxy*)customView; | ||
|
||
@end | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/** | ||
* Appcelerator Titanium Mobile | ||
* Copyright (c) 2013 by Appcelerator, Inc. All Rights Reserved. | ||
* Licensed under the terms of the Apache Public License | ||
* Please see the LICENSE included with this distribution for details. | ||
*/ | ||
#import "TiBase.h" | ||
|
||
#ifdef USE_TI_MAP | ||
|
||
#import "TiMapCustomAnnotationView.h" | ||
|
||
@implementation TiMapCustomAnnotationView | ||
|
||
- (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier map:(TiMapView*)map | ||
{ | ||
if (self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]) { | ||
self.backgroundColor = [UIColor clearColor]; | ||
wrapperView = [[UIView alloc] initWithFrame:CGRectZero]; | ||
wrapperView.userInteractionEnabled = false; | ||
[self addSubview:wrapperView]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)setProxy:(TiViewProxy*)customView; | ||
{ | ||
if (theProxy != customView) { | ||
[[theProxy view] removeFromSuperview]; | ||
RELEASE_TO_NIL(theProxy); | ||
[self initWithProxy:customView]; | ||
} | ||
else { | ||
TiUIView* theView = [theProxy barButtonViewForSize:CGSizeZero]; | ||
self.frame = wrapperView.frame = [theView bounds]; | ||
} | ||
} | ||
|
||
- (void)initWithProxy:(TiViewProxy*)customView | ||
{ | ||
theProxy = [customView retain]; | ||
TiUIView* theView = [theProxy barButtonViewForSize:CGSizeZero]; | ||
self.frame = wrapperView.frame = [theView bounds]; | ||
[wrapperView addSubview:theView]; | ||
} | ||
|
||
-(void)dealloc | ||
{ | ||
RELEASE_TO_NIL(wrapperView); | ||
RELEASE_TO_NIL(lastHitName); | ||
RELEASE_TO_NIL(theProxy); | ||
[super dealloc]; | ||
} | ||
|
||
-(NSString *)lastHitName | ||
{ | ||
NSString * result = lastHitName; | ||
[lastHitName autorelease]; | ||
lastHitName = nil; | ||
return result; | ||
} | ||
|
||
- (UIView *)hitTest:(CGPoint) point withEvent:(UIEvent *)event | ||
{ | ||
UIView * result = [super hitTest:point withEvent:event]; | ||
|
||
if (result==nil) { | ||
for (UIView * ourSubView in [self subviews]) { | ||
CGPoint subPoint = [self convertPoint:point toView:ourSubView]; | ||
for (UIView * ourSubSubView in [ourSubView subviews]) { | ||
if (CGRectContainsPoint([ourSubSubView frame], subPoint) && [ourSubSubView isKindOfClass:[UILabel class]]) { | ||
NSString * labelText = [(UILabel *)ourSubSubView text]; | ||
TiMapAnnotationProxy * ourProxy = (TiMapAnnotationProxy *)[self annotation]; | ||
RELEASE_TO_NIL(lastHitName); | ||
if ([labelText isEqualToString:[ourProxy title]]) { | ||
lastHitName = [@"title" retain]; | ||
} | ||
else if ([labelText isEqualToString:[ourProxy subtitle]]) { | ||
lastHitName = [@"subtitle" retain]; | ||
} | ||
return nil; | ||
} | ||
} | ||
if (CGRectContainsPoint([ourSubView bounds], subPoint)) { | ||
RELEASE_TO_NIL(lastHitName); | ||
lastHitName = [@"annotation" retain]; | ||
return nil; | ||
} | ||
} | ||
} | ||
RELEASE_TO_NIL(lastHitName); | ||
return result; | ||
} | ||
|
||
@end | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
; at the end