Fixing rotation bugs for the most part.

This commit is contained in:
Samuel Clay 2015-09-23 14:37:54 -07:00
parent 2829565167
commit b838723449
5 changed files with 46 additions and 7 deletions

View file

@ -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];

View file

@ -31,6 +31,8 @@ UIActionSheetDelegate> {
NSInteger actionSheetCopyImageIndex;
NSInteger actionSheetSaveImageIndex;
CGSize preRotateSize;
UIInterfaceOrientation _orientation;
}
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;

View file

@ -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<UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
_orientation = [UIApplication sharedApplication].statusBarOrientation;
[self changeWebViewWidth];
[self drawFeedGradient];
} completion:^(id<UIViewControllerTransitionCoordinatorContext> _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 ||

View file

@ -24,7 +24,7 @@
<rect key="frame" x="0.0" y="44" width="414" height="692"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceHorizontal="YES" pagingEnabled="YES" delaysContentTouches="NO" bouncesZoom="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5">
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceHorizontal="YES" pagingEnabled="YES" delaysContentTouches="NO" bouncesZoom="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5">
<rect key="frame" x="0.0" y="0.0" width="414" height="680"/>
<animations/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>

View file

@ -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;