diff --git a/clients/ios/Classes/NewsBlurAppDelegate.m b/clients/ios/Classes/NewsBlurAppDelegate.m index ce52b98d7..198f7ba5e 100644 --- a/clients/ios/Classes/NewsBlurAppDelegate.m +++ b/clients/ios/Classes/NewsBlurAppDelegate.m @@ -174,7 +174,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSString *currentiPhoneVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; - [Fabric with:@[[Crashlytics class]]]; +// [Fabric with:@[[Crashlytics class]]]; [self registerDefaultsFromSettingsBundle]; diff --git a/clients/ios/Classes/StoryDetailViewController.h b/clients/ios/Classes/StoryDetailViewController.h index 9ecbde41d..ce0d5ec48 100644 --- a/clients/ios/Classes/StoryDetailViewController.h +++ b/clients/ios/Classes/StoryDetailViewController.h @@ -31,6 +31,8 @@ UIActionSheetDelegate> { NSInteger actionSheetCopyImageIndex; NSInteger actionSheetSaveImageIndex; CGSize preRotateSize; + + UIInterfaceOrientation _orientation; } @property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate; diff --git a/clients/ios/Classes/StoryDetailViewController.m b/clients/ios/Classes/StoryDetailViewController.m index 39ba0b4bb..7c1481148 100644 --- a/clients/ios/Classes/StoryDetailViewController.m +++ b/clients/ios/Classes/StoryDetailViewController.m @@ -115,6 +115,8 @@ selector:@selector(tapAndHold:) name:@"TapAndHoldNotification" object:nil]; + + _orientation = [UIApplication sharedApplication].statusBarOrientation; } - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { @@ -221,14 +223,29 @@ } } +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + + if (_orientation != [UIApplication sharedApplication].statusBarOrientation) { + _orientation = [UIApplication sharedApplication].statusBarOrientation; + NSLog(@"Found stale orientation in story detail: %@", NSStringFromCGSize(self.view.bounds.size)); + [self.view setNeedsLayout]; + [self.view layoutIfNeeded]; + [self changeWebViewWidth]; + [self drawFeedGradient]; + } +} + - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { + [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; + [coordinator animateAlongsideTransition:^(id _Nonnull context) { + _orientation = [UIApplication sharedApplication].statusBarOrientation; [self changeWebViewWidth]; [self drawFeedGradient]; } completion:^(id _Nonnull context) { }]; - [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; } #pragma mark - @@ -1960,10 +1977,10 @@ shouldStartLoadWithRequest:(NSURLRequest *)request } - (void)changeWebViewWidth { - NSLog(@"changeWebViewWidth: %@ / %@", NSStringFromCGRect(webView.scrollView.bounds), NSStringFromCGSize(webView.scrollView.contentSize)); + NSLog(@"changeWebViewWidth: %@ / %@ / %@", NSStringFromCGSize(self.view.bounds.size), NSStringFromCGSize(webView.scrollView.bounds.size), NSStringFromCGSize(webView.scrollView.contentSize)); [webView.scrollView setContentSize:webView.scrollView.bounds.size]; - NSInteger contentWidth = CGRectGetWidth(self.view.bounds); + NSInteger contentWidth = CGRectGetWidth(webView.scrollView.bounds); UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; NSString *contentWidthClass; @@ -1978,7 +1995,7 @@ shouldStartLoadWithRequest:(NSURLRequest *)request } contentWidthClass = [NSString stringWithFormat:@"%@ NB-width-%d", - contentWidthClass, (int)floorf(CGRectGetWidth(self.view.frame))]; + contentWidthClass, (int)floorf(CGRectGetWidth(webView.scrollView.bounds))]; NSString *riverClass = (appDelegate.storiesCollection.isRiverView || appDelegate.storiesCollection.isSocialView || diff --git a/clients/ios/Classes/StoryPageControl.xib b/clients/ios/Classes/StoryPageControl.xib index 953e475ee..2a0593a84 100644 --- a/clients/ios/Classes/StoryPageControl.xib +++ b/clients/ios/Classes/StoryPageControl.xib @@ -24,7 +24,7 @@ - + diff --git a/clients/ios/Other Sources/NSString+HTML.m b/clients/ios/Other Sources/NSString+HTML.m index dd4ec0adf..b6b3657de 100644 --- a/clients/ios/Other Sources/NSString+HTML.m +++ b/clients/ios/Other Sources/NSString+HTML.m @@ -46,6 +46,10 @@ // Scan and find all tags NSMutableString *result = [[NSMutableString alloc] initWithCapacity:self.length]; + if (!self) { + NSLog(@"nil NSScanner"); + return self; + } NSScanner *scanner = [[NSScanner alloc] initWithString:self]; [scanner setCharactersToBeSkipped:nil]; [scanner setCaseSensitive:YES]; @@ -157,6 +161,10 @@ // Paragraph Separator, U+2029 // Scanner + if (!self) { + NSLog(@"nil NSScanner"); + return self; + } NSScanner *scanner = [[NSScanner alloc] initWithString:self]; [scanner setCharactersToBeSkipped:nil]; NSMutableString *result = [[NSMutableString alloc] init]; @@ -216,6 +224,10 @@ // Paragraph Separator, U+2029 // Scanner + if (!self) { + NSLog(@"nil NSScanner"); + return self; + } NSScanner *scanner = [[NSScanner alloc] initWithString:self]; [scanner setCharactersToBeSkipped:nil]; NSMutableString *result = [[NSMutableString alloc] init]; @@ -274,7 +286,11 @@ if (ampIndex == NSNotFound) { return [NSString stringWithString:self]; // return copy of string as no tags found } - + if (!self) { + NSLog(@"nil NSScanner"); + return self; + } + // Scan and find all tags NSScanner *scanner = [NSScanner scannerWithString:self]; [scanner setCharactersToBeSkipped:nil]; @@ -297,6 +313,10 @@ } while (![scanner isAtEnd]); // Strings + if (!self) { + NSLog(@"nil NSScanner"); + return self; + } NSMutableString *result = [[NSMutableString alloc] initWithString:self]; NSString *finalString;