From 381d8b46997ca8b9000b29dba38e0de206856ccb Mon Sep 17 00:00:00 2001 From: jmkiley Date: Tue, 11 Sep 2018 18:25:32 -0700 Subject: [ios, macos] started to restore iOS 8 support --- platform/darwin/src/MGLAttributionInfo.mm | 6 +-- platform/darwin/src/MGLAttributionInfo_Private.h | 6 +-- platform/darwin/src/MGLCompassDirectionFormatter.m | 4 +- platform/darwin/src/MGLTypes.h | 21 ++++++++ platform/ios/app/Main.storyboard | 62 +++++++++++++--------- platform/ios/src/MGLScaleBar.mm | 6 ++- 6 files changed, 71 insertions(+), 34 deletions(-) diff --git a/platform/darwin/src/MGLAttributionInfo.mm b/platform/darwin/src/MGLAttributionInfo.mm index e8d6a203d0..07d10e852b 100644 --- a/platform/darwin/src/MGLAttributionInfo.mm +++ b/platform/darwin/src/MGLAttributionInfo.mm @@ -16,7 +16,7 @@ @implementation MGLAttributionInfo -+ (NSArray *)attributionInfosFromHTMLString:(nullable NSString *)htmlString fontSize:(CGFloat)fontSize linkColor:(nullable MGLColor *)linkColor { ++ (NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfosFromHTMLString:(nullable NSString *)htmlString fontSize:(CGFloat)fontSize linkColor:(nullable MGLColor *)linkColor { if (!htmlString) { return @[]; } @@ -112,7 +112,7 @@ return infos; } -+ (NSAttributedString *)attributedStringForAttributionInfos:(NSArray *)attributionInfos { ++ (NSAttributedString *)attributedStringForAttributionInfos:(NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfos { NSMutableArray *titles = [NSMutableArray arrayWithCapacity:attributionInfos.count]; for (MGLAttributionInfo *info in attributionInfos) { NSMutableAttributedString *title = info.title.mutableCopy; @@ -259,7 +259,7 @@ } } -- (void)growArrayByAddingAttributionInfosFromArray:(NSArray *)infos { +- (void)growArrayByAddingAttributionInfosFromArray:(NS_ARRAY_OF(MGLAttributionInfo *) *)infos { for (MGLAttributionInfo *info in infos) { [self growArrayByAddingAttributionInfo:info]; } diff --git a/platform/darwin/src/MGLAttributionInfo_Private.h b/platform/darwin/src/MGLAttributionInfo_Private.h index 85c9ed796f..c639752ac3 100644 --- a/platform/darwin/src/MGLAttributionInfo_Private.h +++ b/platform/darwin/src/MGLAttributionInfo_Private.h @@ -16,9 +16,9 @@ NS_ASSUME_NONNULL_BEGIN @param fontSize The default text size in points. @param linkColor The default link color. */ -+ (NSArray *)attributionInfosFromHTMLString:(nullable NSString *)htmlString fontSize:(CGFloat)fontSize linkColor:(nullable MGLColor *)linkColor; ++ (NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfosFromHTMLString:(nullable NSString *)htmlString fontSize:(CGFloat)fontSize linkColor:(nullable MGLColor *)linkColor; -+ (NSAttributedString *)attributedStringForAttributionInfos:(NSArray *)attributionInfos; ++ (NSAttributedString *)attributedStringForAttributionInfos:(NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfos; /** Returns a copy of the `URL` property modified to account for the given style @@ -58,7 +58,7 @@ NS_ASSUME_NONNULL_BEGIN @param infos An array of info objects to add to the receiver. */ -- (void)growArrayByAddingAttributionInfosFromArray:(NSArray *)infos; +- (void)growArrayByAddingAttributionInfosFromArray:(NS_ARRAY_OF(MGLAttributionInfo *) *)infos; @end diff --git a/platform/darwin/src/MGLCompassDirectionFormatter.m b/platform/darwin/src/MGLCompassDirectionFormatter.m index 1ac6a82162..5f0cfae6f7 100644 --- a/platform/darwin/src/MGLCompassDirectionFormatter.m +++ b/platform/darwin/src/MGLCompassDirectionFormatter.m @@ -15,8 +15,8 @@ } - (NSString *)stringFromDirection:(CLLocationDirection)direction { - static NSArray *shortStrings; - static NSArray *longStrings; + static NS_ARRAY_OF(NSString *) *shortStrings; + static NS_ARRAY_OF(NSString *) *longStrings; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ shortStrings = @[ diff --git a/platform/darwin/src/MGLTypes.h b/platform/darwin/src/MGLTypes.h index 1c90d7968b..2eff02fb35 100644 --- a/platform/darwin/src/MGLTypes.h +++ b/platform/darwin/src/MGLTypes.h @@ -112,3 +112,24 @@ NS_INLINE MGLTransition MGLTransitionMake(NSTimeInterval duration, NSTimeInterva } NS_ASSUME_NONNULL_END + +#ifndef NS_ARRAY_OF + +// Foundation collection classes adopted lightweight generics in iOS 9.0 and OS X 10.11 SDKs. +#if __has_feature(objc_generics) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 90000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101100) +/** Inserts a type specifier for a pointer to a lightweight generic with the given collection and object classes. Use a `*` for any non-`id` object classes but no `*` for the collection class. */ +#define NS_ARRAY_OF(ObjectClass...) NSArray +#define NS_MUTABLE_ARRAY_OF(ObjectClass...) NSMutableArray +#define NS_SET_OF(ObjectClass...) NSSet +#define NS_MUTABLE_SET_OF(ObjectClass...) NSMutableSet +#define NS_DICTIONARY_OF(ObjectClass...) NSDictionary +#define NS_MUTABLE_DICTIONARY_OF(ObjectClass...) NSMutableDictionary +#else +#define NS_ARRAY_OF(ObjectClass...) NSArray +#define NS_MUTABLE_ARRAY_OF(ObjectClass...) NSMutableArray +#define NS_SET_OF(ObjectClass...) NSSet +#define NS_MUTABLE_SET_OF(ObjectClass...) NSMutableSet +#define NS_DICTIONARY_OF(ObjectClass...) NSDictionary +#define NS_MUTABLE_DICTIONARY_OF(ObjectClass...) NSMutableDictionary +#endif +#endif diff --git a/platform/ios/app/Main.storyboard b/platform/ios/app/Main.storyboard index 3e8a0ad02a..50d312e18a 100644 --- a/platform/ios/app/Main.storyboard +++ b/platform/ios/app/Main.storyboard @@ -1,15 +1,15 @@ - + - + + - @@ -17,6 +17,10 @@ + + + + @@ -63,7 +67,6 @@ - @@ -220,6 +223,10 @@ + + + + @@ -279,7 +286,7 @@ @@ -365,6 +371,10 @@ + + + + @@ -392,33 +402,32 @@ - - - - - + + + + + - - + + - + - + - + - @@ -437,11 +446,14 @@ + + + + - diff --git a/platform/ios/src/MGLScaleBar.mm b/platform/ios/src/MGLScaleBar.mm index d69fb3e852..a180280adc 100644 --- a/platform/ios/src/MGLScaleBar.mm +++ b/platform/ios/src/MGLScaleBar.mm @@ -205,7 +205,11 @@ static const CGFloat MGLFeetPerMeter = 3.28084; #pragma mark - Convenience methods - (BOOL)usesRightToLeftLayout { - return [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.superview.semanticContentAttribute] == UIUserInterfaceLayoutDirectionRightToLeft; + if ([self.superview respondsToSelector:@selector(semanticContentAttribute)]) { + return [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.superview.semanticContentAttribute] == UIUserInterfaceLayoutDirectionRightToLeft; + } else { + return UIApplication.sharedApplication.userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft; + } } - (BOOL)usesMetricSystem { -- cgit v1.2.1