mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-07 23:03:35 +00:00
[ASMapNode] Toggle user interaction when liveMap changes (#1753)
[ASMapNode] Change map snapshot when updating it with a new region (#1754) [ASMapNode] Commented out code that is causing inaccurate behavior [ASMapNode] Added the ability to zoom in and show annotations, similar to showAnnotations:animated: of MKMapView. Added a basic example for ASMapNode to try out the different changes
This commit is contained in:
parent
21d0f1e10d
commit
83d610cd54
@ -14,6 +14,16 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_OPTIONS(NSUInteger, ASMapNodeShowAnnotationsOptions)
|
||||
{
|
||||
/** The annotations' positions are ignored, use the region or options specified instead. */
|
||||
ASMapNodeShowAnnotationsOptionsIgnored = 0,
|
||||
/** The annotations' positions are used to calculate the region to show in the map, equivalent to showAnnotations:animated. */
|
||||
ASMapNodeShowAnnotationsOptionsZoomed = 1 << 0,
|
||||
/** This will only have an effect if combined with the Zoomed state with liveMap turned on.*/
|
||||
ASMapNodeShowAnnotationsOptionsAnimated = 1 << 1
|
||||
};
|
||||
|
||||
@interface ASMapNode : ASImageNode
|
||||
|
||||
/**
|
||||
@ -54,6 +64,12 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
@property (nonatomic, copy) NSArray<id<MKAnnotation>> *annotations;
|
||||
|
||||
/**
|
||||
* @abstract This property specifies how to show the annotations.
|
||||
* @default Default value is ASMapNodeShowAnnotationsIgnored
|
||||
*/
|
||||
@property (nonatomic, assign) ASMapNodeShowAnnotationsOptions showAnnotationsOptions;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
MKMapSnapshotter *_snapshotter;
|
||||
BOOL _snapshotAfterLayout;
|
||||
NSArray *_annotations;
|
||||
CLLocationCoordinate2D _centerCoordinateOfMap;
|
||||
// CLLocationCoordinate2D _centerCoordinateOfMap;
|
||||
}
|
||||
@end
|
||||
|
||||
@ -46,8 +46,9 @@
|
||||
|
||||
_needsMapReloadOnBoundsChange = YES;
|
||||
_liveMap = NO;
|
||||
_centerCoordinateOfMap = kCLLocationCoordinate2DInvalid;
|
||||
// _centerCoordinateOfMap = kCLLocationCoordinate2DInvalid;
|
||||
_annotations = @[];
|
||||
_showAnnotationsOptions = ASMapNodeShowAnnotationsOptionsIgnored;
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -55,7 +56,6 @@
|
||||
{
|
||||
[super didLoad];
|
||||
if (self.isLiveMap) {
|
||||
self.userInteractionEnabled = YES;
|
||||
[self addLiveMap];
|
||||
}
|
||||
}
|
||||
@ -161,7 +161,18 @@
|
||||
|
||||
- (void)setRegion:(MKCoordinateRegion)region
|
||||
{
|
||||
self.options.region = region;
|
||||
MKMapSnapshotOptions * __weak oldOptions = self.options;
|
||||
MKMapSnapshotOptions * options = [[MKMapSnapshotOptions alloc] init];
|
||||
options.camera = oldOptions.camera;
|
||||
options.mapRect = oldOptions.mapRect;
|
||||
options.mapType = oldOptions.mapType;
|
||||
options.showsPointsOfInterest = oldOptions.showsPointsOfInterest;
|
||||
options.showsBuildings = oldOptions.showsBuildings;
|
||||
options.size = oldOptions.size;
|
||||
options.scale = oldOptions.scale;
|
||||
options.region = region;
|
||||
self.options = options;
|
||||
// self.options.region = region;
|
||||
}
|
||||
|
||||
#pragma mark - Snapshotter
|
||||
@ -257,6 +268,7 @@
|
||||
- (void)addLiveMap
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
self.userInteractionEnabled = YES;
|
||||
if (!_mapView) {
|
||||
__weak ASMapNode *weakSelf = self;
|
||||
_mapView = [[MKMapView alloc] initWithFrame:CGRectZero];
|
||||
@ -266,16 +278,22 @@
|
||||
[weakSelf setNeedsLayout];
|
||||
[weakSelf.view addSubview:_mapView];
|
||||
|
||||
if (CLLocationCoordinate2DIsValid(_centerCoordinateOfMap)) {
|
||||
[_mapView setCenterCoordinate:_centerCoordinateOfMap];
|
||||
if (self.showAnnotationsOptions & ASMapNodeShowAnnotationsOptionsZoomed) {
|
||||
BOOL const animated = self.showAnnotationsOptions & ASMapNodeShowAnnotationsOptionsAnimated;
|
||||
[_mapView showAnnotations:_mapView.annotations animated:animated];
|
||||
}
|
||||
|
||||
// if (CLLocationCoordinate2DIsValid(_centerCoordinateOfMap)) {
|
||||
// [_mapView setCenterCoordinate:_centerCoordinateOfMap];
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
- (void)removeLiveMap
|
||||
{
|
||||
self.userInteractionEnabled = false;
|
||||
// FIXME: With MKCoordinateRegion, isn't the center coordinate fully specified? Do we need this?
|
||||
_centerCoordinateOfMap = _mapView.centerCoordinate;
|
||||
// _centerCoordinateOfMap = _mapView.centerCoordinate;
|
||||
[_mapView removeFromSuperview];
|
||||
_mapView = nil;
|
||||
}
|
||||
@ -295,9 +313,42 @@
|
||||
if (self.isLiveMap) {
|
||||
[_mapView removeAnnotations:_mapView.annotations];
|
||||
[_mapView addAnnotations:annotations];
|
||||
|
||||
if (self.showAnnotationsOptions & ASMapNodeShowAnnotationsOptionsZoomed) {
|
||||
BOOL const animated = self.showAnnotationsOptions & ASMapNodeShowAnnotationsOptionsAnimated;
|
||||
[_mapView showAnnotations:_mapView.annotations animated:animated];
|
||||
}
|
||||
} else {
|
||||
if (self.showAnnotationsOptions & ASMapNodeShowAnnotationsOptionsZoomed) {
|
||||
self.region = [self regionToFitAnnotations:annotations];
|
||||
}
|
||||
else {
|
||||
[self takeSnapshot];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-(MKCoordinateRegion)regionToFitAnnotations:(NSArray<id<MKAnnotation>> *)annotations
|
||||
{
|
||||
if([annotations count] == 0)
|
||||
return MKCoordinateRegionForMapRect(MKMapRectWorld);
|
||||
|
||||
CLLocationCoordinate2D topLeftCoord = CLLocationCoordinate2DMake(-90, 180);
|
||||
CLLocationCoordinate2D bottomRightCoord = CLLocationCoordinate2DMake(90, -180);
|
||||
|
||||
for (id<MKAnnotation> annotation in _annotations) {
|
||||
topLeftCoord = CLLocationCoordinate2DMake(fmax(topLeftCoord.latitude, annotation.coordinate.latitude),
|
||||
fmin(topLeftCoord.longitude, annotation.coordinate.longitude));
|
||||
bottomRightCoord = CLLocationCoordinate2DMake(fmin(bottomRightCoord.latitude, annotation.coordinate.latitude),
|
||||
fmax(bottomRightCoord.longitude, annotation.coordinate.longitude));
|
||||
}
|
||||
|
||||
MKCoordinateRegion region = MKCoordinateRegionMake(CLLocationCoordinate2DMake(topLeftCoord.latitude - (topLeftCoord.latitude - bottomRightCoord.latitude) * 0.5,
|
||||
topLeftCoord.longitude + (bottomRightCoord.longitude - topLeftCoord.longitude) * 0.5),
|
||||
MKCoordinateSpanMake(fabs(topLeftCoord.latitude - bottomRightCoord.latitude) * 2,
|
||||
fabs(bottomRightCoord.longitude - topLeftCoord.longitude) * 2));
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
#pragma mark - Layout
|
||||
|
||||
6
examples/ASMapNode/Podfile
Normal file
6
examples/ASMapNode/Podfile
Normal file
@ -0,0 +1,6 @@
|
||||
source 'https://github.com/CocoaPods/Specs.git'
|
||||
platform :ios, '7.0'
|
||||
target 'Sample' do
|
||||
pod 'AsyncDisplayKit', :path => '../..'
|
||||
end
|
||||
|
||||
377
examples/ASMapNode/Sample.xcodeproj/project.pbxproj
Normal file
377
examples/ASMapNode/Sample.xcodeproj/project.pbxproj
Normal file
@ -0,0 +1,377 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
5CF3EF5E344946731D4F13F2 /* libPods-Sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 465082D55CCF1B0CB1AEBACC /* libPods-Sample.a */; };
|
||||
5E5E62841D13F39400D81E38 /* MapHandlerNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E5E62831D13F39400D81E38 /* MapHandlerNode.m */; };
|
||||
694993D21C8B334F00491CA5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 694993D11C8B334F00491CA5 /* main.m */; };
|
||||
694993D51C8B334F00491CA5 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 694993D41C8B334F00491CA5 /* AppDelegate.m */; };
|
||||
694993D81C8B334F00491CA5 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 694993D71C8B334F00491CA5 /* ViewController.m */; };
|
||||
694993DD1C8B334F00491CA5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 694993DC1C8B334F00491CA5 /* Assets.xcassets */; };
|
||||
694993E01C8B334F00491CA5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 694993DE1C8B334F00491CA5 /* LaunchScreen.storyboard */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
15AD337503831C4D33FF8B3A /* Pods-Sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
465082D55CCF1B0CB1AEBACC /* libPods-Sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Sample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
5E5E62821D13F39400D81E38 /* MapHandlerNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapHandlerNode.h; sourceTree = "<group>"; };
|
||||
5E5E62831D13F39400D81E38 /* MapHandlerNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MapHandlerNode.m; sourceTree = "<group>"; };
|
||||
694993CD1C8B334F00491CA5 /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
694993D11C8B334F00491CA5 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
694993D31C8B334F00491CA5 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
694993D41C8B334F00491CA5 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||
694993D61C8B334F00491CA5 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
|
||||
694993D71C8B334F00491CA5 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
|
||||
694993DC1C8B334F00491CA5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
694993DF1C8B334F00491CA5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
694993E11C8B334F00491CA5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
97482F27BE2F7583EFE1BC2C /* Pods-Sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.release.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
694993CA1C8B334F00491CA5 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5CF3EF5E344946731D4F13F2 /* libPods-Sample.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
0DFDB4376BA084DAC7C1976E /* Pods */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
15AD337503831C4D33FF8B3A /* Pods-Sample.debug.xcconfig */,
|
||||
97482F27BE2F7583EFE1BC2C /* Pods-Sample.release.xcconfig */,
|
||||
);
|
||||
name = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
478C8D7C412DCBDFE14640D8 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
465082D55CCF1B0CB1AEBACC /* libPods-Sample.a */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
694993C41C8B334F00491CA5 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
694993CF1C8B334F00491CA5 /* Sample */,
|
||||
694993CE1C8B334F00491CA5 /* Products */,
|
||||
0DFDB4376BA084DAC7C1976E /* Pods */,
|
||||
478C8D7C412DCBDFE14640D8 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
694993CE1C8B334F00491CA5 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
694993CD1C8B334F00491CA5 /* Sample.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
694993CF1C8B334F00491CA5 /* Sample */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
694993D31C8B334F00491CA5 /* AppDelegate.h */,
|
||||
694993D41C8B334F00491CA5 /* AppDelegate.m */,
|
||||
694993D61C8B334F00491CA5 /* ViewController.h */,
|
||||
694993D71C8B334F00491CA5 /* ViewController.m */,
|
||||
5E5E62821D13F39400D81E38 /* MapHandlerNode.h */,
|
||||
5E5E62831D13F39400D81E38 /* MapHandlerNode.m */,
|
||||
694993DC1C8B334F00491CA5 /* Assets.xcassets */,
|
||||
694993D01C8B334F00491CA5 /* Supporting Files */,
|
||||
);
|
||||
path = Sample;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
694993D01C8B334F00491CA5 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
694993E11C8B334F00491CA5 /* Info.plist */,
|
||||
694993DE1C8B334F00491CA5 /* LaunchScreen.storyboard */,
|
||||
694993D11C8B334F00491CA5 /* main.m */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
694993CC1C8B334F00491CA5 /* Sample */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 694993E41C8B334F00491CA5 /* Build configuration list for PBXNativeTarget "Sample" */;
|
||||
buildPhases = (
|
||||
80035273449C25F4B2E1454F /* [CP] Check Pods Manifest.lock */,
|
||||
694993C91C8B334F00491CA5 /* Sources */,
|
||||
694993CA1C8B334F00491CA5 /* Frameworks */,
|
||||
694993CB1C8B334F00491CA5 /* Resources */,
|
||||
06EE2E0ABEB6289D4775A867 /* [CP] Copy Pods Resources */,
|
||||
23FC03B282CBD9014D868DF6 /* [CP] Embed Pods Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = Sample;
|
||||
productName = Sample;
|
||||
productReference = 694993CD1C8B334F00491CA5 /* Sample.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
694993C51C8B334F00491CA5 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0720;
|
||||
ORGANIZATIONNAME = AsyncDisplayKit;
|
||||
TargetAttributes = {
|
||||
694993CC1C8B334F00491CA5 = {
|
||||
CreatedOnToolsVersion = 7.2.1;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 694993C81C8B334F00491CA5 /* Build configuration list for PBXProject "Sample" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 694993C41C8B334F00491CA5;
|
||||
productRefGroup = 694993CE1C8B334F00491CA5 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
694993CC1C8B334F00491CA5 /* Sample */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
694993CB1C8B334F00491CA5 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
694993E01C8B334F00491CA5 /* LaunchScreen.storyboard in Resources */,
|
||||
694993DD1C8B334F00491CA5 /* Assets.xcassets in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
06EE2E0ABEB6289D4775A867 /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
23FC03B282CBD9014D868DF6 /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
80035273449C25F4B2E1454F /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
694993C91C8B334F00491CA5 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5E5E62841D13F39400D81E38 /* MapHandlerNode.m in Sources */,
|
||||
694993D81C8B334F00491CA5 /* ViewController.m in Sources */,
|
||||
694993D51C8B334F00491CA5 /* AppDelegate.m in Sources */,
|
||||
694993D21C8B334F00491CA5 /* main.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
694993DE1C8B334F00491CA5 /* LaunchScreen.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
694993DF1C8B334F00491CA5 /* Base */,
|
||||
);
|
||||
name = LaunchScreen.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
694993E21C8B334F00491CA5 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
694993E31C8B334F00491CA5 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
694993E51C8B334F00491CA5 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 15AD337503831C4D33FF8B3A /* Pods-Sample.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
INFOPLIST_FILE = Sample/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.AsyncDisplayKit.Sample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
694993E61C8B334F00491CA5 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 97482F27BE2F7583EFE1BC2C /* Pods-Sample.release.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
INFOPLIST_FILE = Sample/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.AsyncDisplayKit.Sample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
694993C81C8B334F00491CA5 /* Build configuration list for PBXProject "Sample" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
694993E21C8B334F00491CA5 /* Debug */,
|
||||
694993E31C8B334F00491CA5 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
694993E41C8B334F00491CA5 /* Build configuration list for PBXNativeTarget "Sample" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
694993E51C8B334F00491CA5 /* Debug */,
|
||||
694993E61C8B334F00491CA5 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 694993C51C8B334F00491CA5 /* Project object */;
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0720"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "694993CC1C8B334F00491CA5"
|
||||
BuildableName = "Sample.app"
|
||||
BlueprintName = "Sample"
|
||||
ReferencedContainer = "container:Sample.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "694993CC1C8B334F00491CA5"
|
||||
BuildableName = "Sample.app"
|
||||
BlueprintName = "Sample"
|
||||
ReferencedContainer = "container:Sample.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "694993CC1C8B334F00491CA5"
|
||||
BuildableName = "Sample.app"
|
||||
BlueprintName = "Sample"
|
||||
ReferencedContainer = "container:Sample.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "694993CC1C8B334F00491CA5"
|
||||
BuildableName = "Sample.app"
|
||||
BlueprintName = "Sample"
|
||||
ReferencedContainer = "container:Sample.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
26
examples/ASMapNode/Sample/AppDelegate.h
Normal file
26
examples/ASMapNode/Sample/AppDelegate.h
Normal file
@ -0,0 +1,26 @@
|
||||
//
|
||||
// AppDelegate.h
|
||||
// Sample
|
||||
//
|
||||
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
// This source code is licensed under the BSD-style license found in the
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface AppDelegate : UIResponder <UIApplicationDelegate>
|
||||
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
36
examples/ASMapNode/Sample/AppDelegate.m
Normal file
36
examples/ASMapNode/Sample/AppDelegate.m
Normal file
@ -0,0 +1,36 @@
|
||||
//
|
||||
// AppDelegate.m
|
||||
// Sample
|
||||
//
|
||||
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
// This source code is licensed under the BSD-style license found in the
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "ViewController.h"
|
||||
|
||||
@interface AppDelegate ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
// Override point for customization after application launch.
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
self.window.backgroundColor = [UIColor whiteColor];
|
||||
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[ViewController new]];
|
||||
[self.window makeKeyAndVisible];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
@ -0,0 +1,38 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "40x40",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "40x40",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "60x60",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "60x60",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
27
examples/ASMapNode/Sample/Base.lproj/LaunchScreen.storyboard
Normal file
27
examples/ASMapNode/Sample/Base.lproj/LaunchScreen.storyboard
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="53" y="375"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
43
examples/ASMapNode/Sample/Info.plist
Normal file
43
examples/ASMapNode/Sample/Info.plist
Normal file
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
24
examples/ASMapNode/Sample/MapHandlerNode.h
Normal file
24
examples/ASMapNode/Sample/MapHandlerNode.h
Normal file
@ -0,0 +1,24 @@
|
||||
//
|
||||
// MapHandlerNode.h
|
||||
// Sample
|
||||
//
|
||||
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
// This source code is licensed under the BSD-style license found in the
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#import <AsyncDisplayKit/ASDisplayNode.h>
|
||||
|
||||
@interface MapHandlerNode : ASDisplayNode
|
||||
|
||||
|
||||
@end
|
||||
|
||||
262
examples/ASMapNode/Sample/MapHandlerNode.m
Normal file
262
examples/ASMapNode/Sample/MapHandlerNode.m
Normal file
@ -0,0 +1,262 @@
|
||||
//
|
||||
// MapHandlerNode.m
|
||||
// Sample
|
||||
//
|
||||
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
// This source code is licensed under the BSD-style license found in the
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#import "MapHandlerNode.h"
|
||||
|
||||
#import <AsyncDisplayKit/ASDisplayNode+Subclasses.h>
|
||||
|
||||
#import <AsyncDisplayKit/ASMapNode.h>
|
||||
#import <AsyncDisplayKit/ASButtonNode.h>
|
||||
#import <AsyncDisplayKit/ASEditableTextNode.h>
|
||||
|
||||
#import <AsyncDisplayKit/ASStackLayoutSpec.h>
|
||||
#import <AsyncDisplayKit/ASInsetLayoutSpec.h>
|
||||
|
||||
@interface MapHandlerNode () <ASEditableTextNodeDelegate, MKMapViewDelegate>
|
||||
|
||||
@property (nonatomic, strong) ASEditableTextNode * latEditableNode;
|
||||
@property (nonatomic, strong) ASEditableTextNode * lonEditableNode;
|
||||
@property (nonatomic, strong) ASEditableTextNode * deltaLatEditableNode;
|
||||
@property (nonatomic, strong) ASEditableTextNode * deltaLonEditableNode;
|
||||
@property (nonatomic, strong) ASButtonNode * updateRegionButton;
|
||||
@property (nonatomic, strong) ASButtonNode * liveMapToggleButton;
|
||||
@property (nonatomic, strong) ASMapNode * mapNode;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MapHandlerNode
|
||||
|
||||
#pragma mark - Lifecycle
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (!(self = [super init]))
|
||||
return nil;
|
||||
|
||||
_latEditableNode = [[ASEditableTextNode alloc] init];
|
||||
_lonEditableNode = [[ASEditableTextNode alloc] init];
|
||||
_deltaLatEditableNode = [[ASEditableTextNode alloc] init];
|
||||
_deltaLonEditableNode = [[ASEditableTextNode alloc] init];
|
||||
|
||||
_updateRegionButton = [[ASButtonNode alloc] init];
|
||||
_liveMapToggleButton = [[ASButtonNode alloc] init];
|
||||
_mapNode = [[ASMapNode alloc] init];
|
||||
|
||||
[self addSubnode:_latEditableNode];
|
||||
[self addSubnode:_lonEditableNode];
|
||||
[self addSubnode:_deltaLatEditableNode];
|
||||
[self addSubnode:_deltaLonEditableNode];
|
||||
|
||||
[self addSubnode:_updateRegionButton];
|
||||
[self addSubnode:_liveMapToggleButton];
|
||||
[self addSubnode:_mapNode];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)didLoad
|
||||
{
|
||||
[super didLoad];
|
||||
|
||||
_latEditableNode.attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%f", _mapNode.region.center.latitude]];
|
||||
_lonEditableNode.attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%f", _mapNode.region.center.longitude]];
|
||||
_deltaLatEditableNode.attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%f", _mapNode.region.span.latitudeDelta]];
|
||||
_deltaLonEditableNode.attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%f", _mapNode.region.span.longitudeDelta]];
|
||||
|
||||
[self configureEditableNodes:_latEditableNode];
|
||||
[self configureEditableNodes:_lonEditableNode];
|
||||
[self configureEditableNodes:_deltaLatEditableNode];
|
||||
[self configureEditableNodes:_deltaLonEditableNode];
|
||||
|
||||
_mapNode.mapDelegate = self;
|
||||
|
||||
[_updateRegionButton setTitle:@"Update Region" withFont:nil withColor:[UIColor blueColor] forState:ASControlStateNormal];
|
||||
[_updateRegionButton setTitle:@"Update Region" withFont:[UIFont systemFontOfSize:14] withColor:[UIColor blueColor] forState:ASControlStateHighlighted];
|
||||
[_updateRegionButton addTarget:self action:@selector(updateRegion) forControlEvents:ASControlNodeEventTouchUpInside];
|
||||
[_liveMapToggleButton setTitle:[self liveMapStr] withFont:nil withColor:[UIColor blueColor] forState:ASControlStateNormal];
|
||||
[_liveMapToggleButton setTitle:[self liveMapStr] withFont:[UIFont systemFontOfSize:14] withColor:[UIColor blueColor] forState:ASControlStateHighlighted];
|
||||
[_liveMapToggleButton addTarget:self action:@selector(toggleLiveMap) forControlEvents:ASControlNodeEventTouchUpInside];
|
||||
}
|
||||
|
||||
#pragma mark - Layout
|
||||
|
||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||
{
|
||||
#define SPACING 5
|
||||
#define HEIGHT 30
|
||||
CGSize preferredSize = CGSizeMake(constrainedSize.max.width * 0.3, HEIGHT);
|
||||
|
||||
_latEditableNode.preferredFrameSize = _lonEditableNode.preferredFrameSize = preferredSize;
|
||||
_deltaLatEditableNode.preferredFrameSize = _deltaLonEditableNode.preferredFrameSize = preferredSize;
|
||||
_updateRegionButton.preferredFrameSize = _liveMapToggleButton.preferredFrameSize = preferredSize;
|
||||
|
||||
_latEditableNode.flexGrow = _lonEditableNode.flexGrow = true;
|
||||
_deltaLatEditableNode.flexGrow = _deltaLonEditableNode.flexGrow = true;
|
||||
_updateRegionButton.flexGrow = _liveMapToggleButton.flexGrow = true;
|
||||
|
||||
_mapNode.flexGrow = true;
|
||||
|
||||
ASStackLayoutSpec * lonlatSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal
|
||||
spacing:SPACING
|
||||
justifyContent:ASStackLayoutJustifyContentStart
|
||||
alignItems:ASStackLayoutAlignItemsCenter
|
||||
children:@[_latEditableNode, _lonEditableNode]];
|
||||
lonlatSpec.flexGrow = true;
|
||||
|
||||
ASStackLayoutSpec * deltaLonlatSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal
|
||||
spacing:SPACING
|
||||
justifyContent:ASStackLayoutJustifyContentStart
|
||||
alignItems:ASStackLayoutAlignItemsCenter
|
||||
children:@[_deltaLatEditableNode, _deltaLonEditableNode]];
|
||||
deltaLonlatSpec.flexGrow = true;
|
||||
|
||||
ASStackLayoutSpec * lonlatConfigSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical
|
||||
spacing:SPACING
|
||||
justifyContent:ASStackLayoutJustifyContentStart
|
||||
alignItems:ASStackLayoutAlignItemsStretch
|
||||
children:@[lonlatSpec, deltaLonlatSpec]];
|
||||
lonlatConfigSpec.flexGrow = true;
|
||||
|
||||
ASStackLayoutSpec * buttonsSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical
|
||||
spacing:SPACING
|
||||
justifyContent:ASStackLayoutJustifyContentStart
|
||||
alignItems:ASStackLayoutAlignItemsStretch
|
||||
children:@[_updateRegionButton, _liveMapToggleButton]];
|
||||
buttonsSpec.flexGrow = true;
|
||||
|
||||
ASStackLayoutSpec * dashboardSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal
|
||||
spacing:SPACING
|
||||
justifyContent:ASStackLayoutJustifyContentStart
|
||||
alignItems:ASStackLayoutAlignItemsStretch
|
||||
children:@[lonlatConfigSpec, buttonsSpec]];
|
||||
dashboardSpec.flexGrow = true;
|
||||
|
||||
ASInsetLayoutSpec * insetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(20, 10, 0, 10) child:dashboardSpec];
|
||||
|
||||
ASStackLayoutSpec * layoutSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical
|
||||
spacing:SPACING
|
||||
justifyContent:ASStackLayoutJustifyContentStart
|
||||
alignItems:ASStackLayoutAlignItemsStretch
|
||||
children:@[insetSpec, _mapNode ]];
|
||||
return layoutSpec;
|
||||
}
|
||||
|
||||
#pragma mark - Button actions
|
||||
|
||||
-(void)updateRegion
|
||||
{
|
||||
NSNumberFormatter *f = [[NSNumberFormatter alloc] init];
|
||||
f.numberStyle = NSNumberFormatterDecimalStyle;
|
||||
|
||||
double const lat = [f numberFromString:_latEditableNode.attributedText.string].doubleValue;
|
||||
double const lon = [f numberFromString:_lonEditableNode.attributedText.string].doubleValue;
|
||||
double const deltaLat = [f numberFromString:_deltaLatEditableNode.attributedText.string].doubleValue;
|
||||
double const deltaLon = [f numberFromString:_deltaLonEditableNode.attributedText.string].doubleValue;
|
||||
|
||||
MKCoordinateRegion region = MKCoordinateRegionMake(CLLocationCoordinate2DMake(lat, lon),
|
||||
MKCoordinateSpanMake(deltaLat, deltaLon));
|
||||
|
||||
_mapNode.region = region;
|
||||
|
||||
// MKMapSnapshotOptions * __weak oldOptions = _mapNode.options;
|
||||
// MKMapSnapshotOptions * options = [[MKMapSnapshotOptions alloc] init];
|
||||
// options.camera = oldOptions.camera;
|
||||
// options.mapRect = oldOptions.mapRect;
|
||||
// options.mapType = oldOptions.mapType;
|
||||
// options.showsPointsOfInterest = oldOptions.showsPointsOfInterest;
|
||||
// options.showsBuildings = oldOptions.showsBuildings;
|
||||
// options.size = oldOptions.size;
|
||||
// options.scale = oldOptions.scale;
|
||||
// options.region = region;
|
||||
// _mapNode.options = options;
|
||||
|
||||
NSLog(@"Region updated");
|
||||
}
|
||||
|
||||
-(void)toggleLiveMap
|
||||
{
|
||||
_mapNode.liveMap = !_mapNode.liveMap;
|
||||
NSString * const liveMapStr = [self liveMapStr];
|
||||
[_liveMapToggleButton setTitle:liveMapStr withFont:nil withColor:[UIColor blueColor] forState:ASControlStateNormal];
|
||||
[_liveMapToggleButton setTitle:liveMapStr withFont:[UIFont systemFontOfSize:14] withColor:[UIColor blueColor] forState:ASControlStateHighlighted];
|
||||
NSLog(@"UserInteractionEnabled: %i", _mapNode.userInteractionEnabled);
|
||||
}
|
||||
|
||||
#pragma mark - Helpers
|
||||
|
||||
-(NSString *)liveMapStr
|
||||
{
|
||||
return _mapNode.liveMap ? @"Live Map is ON" : @"Live Map is OFF";
|
||||
}
|
||||
|
||||
-(void)configureEditableNodes:(ASEditableTextNode *)node
|
||||
{
|
||||
node.returnKeyType = node == _deltaLonEditableNode ? UIReturnKeyDone : UIReturnKeyNext;
|
||||
node.delegate = self;
|
||||
}
|
||||
|
||||
#pragma mark - ASEditableTextNodeDelegate
|
||||
|
||||
- (BOOL)editableTextNode:(ASEditableTextNode *)editableTextNode shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
|
||||
{
|
||||
if([text isEqualToString:@"\n"]) {
|
||||
if(editableTextNode == _latEditableNode)
|
||||
[_lonEditableNode becomeFirstResponder];
|
||||
else if(editableTextNode == _lonEditableNode)
|
||||
[_deltaLatEditableNode becomeFirstResponder];
|
||||
else if(editableTextNode == _deltaLatEditableNode)
|
||||
[_deltaLonEditableNode becomeFirstResponder];
|
||||
else if(editableTextNode == _deltaLonEditableNode) {
|
||||
[_deltaLonEditableNode resignFirstResponder];
|
||||
[self updateRegion];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSMutableCharacterSet * s = [NSMutableCharacterSet characterSetWithCharactersInString:@".-"];
|
||||
[s formUnionWithCharacterSet:[NSCharacterSet decimalDigitCharacterSet]];
|
||||
[s invert];
|
||||
|
||||
NSRange r = [text rangeOfCharacterFromSet:s];
|
||||
if(r.location != NSNotFound) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if([editableTextNode.attributedText.string rangeOfString:@"."].location != NSNotFound &&
|
||||
[text rangeOfString:@"."].location != NSNotFound) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ([editableTextNode.attributedText.string rangeOfString:@"-"].location != NSNotFound &&
|
||||
[text rangeOfString:@"-"].location != NSNotFound &&
|
||||
range.location > 0) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark - MKMapViewDelegate
|
||||
|
||||
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
|
||||
_latEditableNode.attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%f", mapView.region.center.latitude]];
|
||||
_lonEditableNode.attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%f", mapView.region.center.longitude]];
|
||||
_deltaLatEditableNode.attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%f", mapView.region.span.latitudeDelta]];
|
||||
_deltaLonEditableNode.attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%f", mapView.region.span.longitudeDelta]];
|
||||
}
|
||||
|
||||
@end
|
||||
24
examples/ASMapNode/Sample/ViewController.h
Normal file
24
examples/ASMapNode/Sample/ViewController.h
Normal file
@ -0,0 +1,24 @@
|
||||
//
|
||||
// ViewController.h
|
||||
// Sample
|
||||
//
|
||||
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
// This source code is licensed under the BSD-style license found in the
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#import <AsyncDisplayKit/ASViewController.h>
|
||||
|
||||
@interface ViewController : ASViewController
|
||||
|
||||
|
||||
@end
|
||||
|
||||
53
examples/ASMapNode/Sample/ViewController.m
Normal file
53
examples/ASMapNode/Sample/ViewController.m
Normal file
@ -0,0 +1,53 @@
|
||||
//
|
||||
// ViewController.m
|
||||
// Sample
|
||||
//
|
||||
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
// This source code is licensed under the BSD-style license found in the
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#import "ViewController.h"
|
||||
|
||||
#import "MapHandlerNode.h"
|
||||
|
||||
@interface ViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation ViewController
|
||||
|
||||
|
||||
#pragma mark - Lifecycle
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super initWithNode:[[MapHandlerNode alloc] init]];
|
||||
if (self == nil) { return self; }
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - UIViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
self.navigationController.navigationBarHidden = true;
|
||||
}
|
||||
|
||||
@end
|
||||
25
examples/ASMapNode/Sample/main.m
Normal file
25
examples/ASMapNode/Sample/main.m
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// main.m
|
||||
// Sample
|
||||
//
|
||||
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
// This source code is licensed under the BSD-style license found in the
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "AppDelegate.h"
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user