diff --git a/Libraries/Text/TextInput/Multiline/RCTUITextView.m b/Libraries/Text/TextInput/Multiline/RCTUITextView.m index 39412eff9..fb1d9638d 100644 --- a/Libraries/Text/TextInput/Multiline/RCTUITextView.m +++ b/Libraries/Text/TextInput/Multiline/RCTUITextView.m @@ -222,37 +222,12 @@ static UIColor *defaultPlaceholderColor() - (CGSize)sizeThatFits:(CGSize)size { // Returned fitting size depends on text size and placeholder size. - CGSize textSize = [self fixedSizeThatFits:size]; + CGSize textSize = [super sizeThatFits:size]; CGSize placeholderSize = self.placeholderSize; // Returning size DOES contain `textContainerInset` (aka `padding`). return CGSizeMake(MAX(textSize.width, placeholderSize.width), MAX(textSize.height, placeholderSize.height)); } -- (CGSize)fixedSizeThatFits:(CGSize)size -{ - // UITextView on iOS 8 has a bug that automatically scrolls to the top - // when calling `sizeThatFits:`. Use a copy so that self is not screwed up. - static BOOL useCustomImplementation = NO; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - useCustomImplementation = ![[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){9,0,0}]; - }); - - if (!useCustomImplementation) { - return [super sizeThatFits:size]; - } - - if (!_detachedTextView) { - _detachedTextView = [UITextView new]; - } - - _detachedTextView.attributedText = self.attributedText; - _detachedTextView.font = self.font; - _detachedTextView.textContainerInset = self.textContainerInset; - - return [_detachedTextView sizeThatFits:size]; -} - #pragma mark - Context Menu - (BOOL)canPerformAction:(SEL)action withSender:(id)sender diff --git a/React/Base/RCTKeyCommands.m b/React/Base/RCTKeyCommands.m index 4bde8957c..8f8f19b83 100644 --- a/React/Base/RCTKeyCommands.m +++ b/React/Base/RCTKeyCommands.m @@ -14,11 +14,6 @@ #if RCT_DEV -static BOOL RCTIsIOS8OrEarlier() -{ - return [UIDevice currentDevice].systemVersion.floatValue < 9; -} - @interface RCTKeyCommand : NSObject @property (nonatomic, strong) UIKeyCommand *keyCommand; @@ -119,7 +114,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) // NOTE: throttle the key handler because on iOS 9 the handleKeyCommand: // method gets called repeatedly if the command key is held down. static NSTimeInterval lastCommand = 0; - if (RCTIsIOS8OrEarlier() || CACurrentMediaTime() - lastCommand > 0.5) { + if (CACurrentMediaTime() - lastCommand > 0.5) { for (RCTKeyCommand *command in [RCTKeyCommands sharedInstance].commands) { if ([command.keyCommand.input isEqualToString:key.input] && command.keyCommand.modifierFlags == key.modifierFlags) { @@ -171,7 +166,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) // NOTE: throttle the key handler because on iOS 9 the handleKeyCommand: // method gets called repeatedly if the command key is held down. - if (RCTIsIOS8OrEarlier() || CACurrentMediaTime() - lastDoubleCommand > 0.5) { + if (CACurrentMediaTime() - lastDoubleCommand > 0.5) { command.block(key); lastDoubleCommand = CACurrentMediaTime(); } @@ -189,44 +184,14 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) @end -@implementation UIApplication (RCTKeyCommands) - -// Required for iOS 8.x -- (BOOL)RCT_sendAction:(SEL)action to:(id)target from:(id)sender forEvent:(UIEvent *)event -{ - if (action == @selector(RCT_handleKeyCommand:)) { - [self RCT_handleKeyCommand:sender]; - return YES; - } else if (action == @selector(RCT_handleDoublePressKeyCommand:)) { - [self RCT_handleDoublePressKeyCommand:sender]; - return YES; - } - return [self RCT_sendAction:action to:target from:sender forEvent:event]; -} - -@end - @implementation RCTKeyCommands + (void)initialize { - if (RCTIsIOS8OrEarlier()) { - - // swizzle UIApplication - RCTSwapInstanceMethods([UIApplication class], - @selector(keyCommands), - @selector(RCT_keyCommands)); - - RCTSwapInstanceMethods([UIApplication class], - @selector(sendAction:to:from:forEvent:), - @selector(RCT_sendAction:to:from:forEvent:)); - } else { - - // swizzle UIResponder - RCTSwapInstanceMethods([UIResponder class], - @selector(keyCommands), - @selector(RCT_keyCommands)); - } + // swizzle UIResponder + RCTSwapInstanceMethods([UIResponder class], + @selector(keyCommands), + @selector(RCT_keyCommands)); } + (instancetype)sharedInstance @@ -254,17 +219,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) { RCTAssertMainQueue(); - if (input.length && flags && RCTIsIOS8OrEarlier()) { - - // Workaround around the first cmd not working: http://openradar.appspot.com/19613391 - // You can register just the cmd key and do nothing. This ensures that - // command-key modified commands will work first time. Fixed in iOS 9. - - [self registerKeyCommandWithInput:@"" - modifierFlags:flags - action:nil]; - } - UIKeyCommand *command = [UIKeyCommand keyCommandWithInput:input modifierFlags:flags action:@selector(RCT_handleKeyCommand:)]; @@ -306,17 +260,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) { RCTAssertMainQueue(); - if (input.length && flags && RCTIsIOS8OrEarlier()) { - - // Workaround around the first cmd not working: http://openradar.appspot.com/19613391 - // You can register just the cmd key and do nothing. This ensures that - // command-key modified commands will work first time. Fixed in iOS 9. - - [self registerDoublePressKeyCommandWithInput:@"" - modifierFlags:flags - action:nil]; - } - UIKeyCommand *command = [UIKeyCommand keyCommandWithInput:input modifierFlags:flags action:@selector(RCT_handleDoublePressKeyCommand:)]; diff --git a/React/Base/RCTMultipartDataTask.m b/React/Base/RCTMultipartDataTask.m index 3708a7d35..285eaa9aa 100644 --- a/React/Base/RCTMultipartDataTask.m +++ b/React/Base/RCTMultipartDataTask.m @@ -11,20 +11,6 @@ @end -// We need this ugly runtime check because [streamTask captureStreams] below fails on iOS version -// earlier than 9.0. Unfortunately none of the proper ways of checking worked: -// -// - NSURLSessionStreamTask class is available and is not Null on iOS 8 -// - [[NSURLSessionStreamTask new] respondsToSelector:@selector(captureStreams)] is always NO -// - The instance we get in URLSession:dataTask:didBecomeStreamTask: is of __NSCFURLLocalStreamTaskFromDataTask -// and it responds to captureStreams on iOS 9+ but doesn't on iOS 8. Which means we can't get direct access -// to the streams on iOS 8 and at that point it's too late to change the behavior back to dataTask -// - The compile-time #ifdef's can't be used because an app compiled for iOS8 can still run on iOS9 - -static BOOL isStreamTaskSupported() { - return [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){9,0,0}]; -} - @implementation RCTMultipartDataTask { NSURL *_url; RCTMultipartDataTaskCallback _partHandler; @@ -52,9 +38,7 @@ static BOOL isStreamTaskSupported() { NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:nil]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:_url]; - if (isStreamTaskSupported()) { - [request addValue:@"multipart/mixed" forHTTPHeaderField:@"Accept"]; - } + [request addValue:@"multipart/mixed" forHTTPHeaderField:@"Accept"]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request]; [dataTask resume]; [session finishTasksAndInvalidate]; diff --git a/React/Views/RCTFont.mm b/React/Views/RCTFont.mm index f36f5438e..e68663795 100644 --- a/React/Views/RCTFont.mm +++ b/React/Views/RCTFont.mm @@ -142,19 +142,8 @@ static UIFont *cachedSystemFont(CGFloat size, RCTFontWeight weight) if (defaultFontHandler) { NSString *fontWeightDescription = FontWeightDescriptionFromUIFontWeight(weight); font = defaultFontHandler(size, fontWeightDescription); - } else if ([UIFont respondsToSelector:@selector(systemFontOfSize:weight:)]) { - // Only supported on iOS8.2 and above - font = [UIFont systemFontOfSize:size weight:weight]; } else { - if (weight >= UIFontWeightBold) { - font = [UIFont boldSystemFontOfSize:size]; - } else if (weight >= UIFontWeightMedium) { - font = [UIFont fontWithName:@"HelveticaNeue-Medium" size:size]; - } else if (weight <= UIFontWeightLight) { - font = [UIFont fontWithName:@"HelveticaNeue-Light" size:size]; - } else { - font = [UIFont systemFontOfSize:size]; - } + font = [UIFont systemFontOfSize:size weight:weight]; } {