mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
+ Fixed Navigationbar/Statusbar quirks in Annotation View Controller
This commit is contained in:
@@ -96,6 +96,8 @@ typedef NS_ENUM(NSInteger, BITImageAnnotationViewControllerInteractionMode) {
|
||||
|
||||
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc ] initWithImage:bit_imageNamed(@"Cancel.png", BITHOCKEYSDK_BUNDLE) landscapeImagePhone:bit_imageNamed(@"Cancel.png", BITHOCKEYSDK_BUNDLE) style:UIBarButtonItemStyleBordered target:self action:@selector(discard:)];
|
||||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc ] initWithImage:bit_imageNamed(@"Ok.png", BITHOCKEYSDK_BUNDLE) landscapeImagePhone:bit_imageNamed(@"Ok.png", BITHOCKEYSDK_BUNDLE) style:UIBarButtonItemStyleBordered target:self action:@selector(save:)];
|
||||
|
||||
self.view.autoresizesSubviews = NO;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,19 +108,21 @@ typedef NS_ENUM(NSInteger, BITImageAnnotationViewControllerInteractionMode) {
|
||||
}
|
||||
|
||||
- (BOOL)prefersStatusBarHidden {
|
||||
return self.navigationController.navigationBarHidden;
|
||||
return self.navigationController.navigationBarHidden || self.navigationController.navigationBar.alpha == 0.0f;
|
||||
}
|
||||
|
||||
|
||||
- (void)fitImageViewFrame {
|
||||
CGFloat heightScaleFactor = self.view.frame.size.height / self.image.size.height;
|
||||
CGFloat widthScaleFactor = self.view.frame.size.width / self.image.size.width;
|
||||
CGFloat heightScaleFactor = [[UIScreen mainScreen] bounds].size.height / self.image.size.height;
|
||||
CGFloat widthScaleFactor = [[UIScreen mainScreen] bounds].size.width / self.image.size.width;
|
||||
|
||||
CGFloat factor = MIN(heightScaleFactor, widthScaleFactor);
|
||||
self.scaleFactor = factor;
|
||||
CGSize scaledImageSize = CGSizeMake(self.image.size.width * factor, self.image.size.height * factor);
|
||||
|
||||
self.imageView.frame = CGRectMake(self.view.frame.size.width/2 - scaledImageSize.width/2, self.view.frame.size.height/2 - scaledImageSize.height/2, scaledImageSize.width, scaledImageSize.height);
|
||||
CGRect baseFrame = CGRectMake(self.view.frame.size.width/2 - scaledImageSize.width/2, self.view.frame.size.height - [[UIScreen mainScreen] bounds].size.height, scaledImageSize.width, scaledImageSize.height);
|
||||
|
||||
self.imageView.frame = baseFrame;
|
||||
}
|
||||
|
||||
-(void)editingAction:(id)sender {
|
||||
@@ -305,19 +309,40 @@ typedef NS_ENUM(NSInteger, BITImageAnnotationViewControllerInteractionMode) {
|
||||
}
|
||||
|
||||
-(void)tapped:(UIGestureRecognizer *)tapRecognizer {
|
||||
if (self.navigationController.navigationBarHidden){
|
||||
// This toggles the nav and status bar. Since iOS7 and pre-iOS7 behave weirdly different,
|
||||
// this might look rather hacky, but hiding the navbar under iOS6 leads to some ugly
|
||||
// animation effect which is avoided by simply hiding the navbar setting it's alpha to 0. // moritzh
|
||||
|
||||
if (self.navigationController.navigationBar.alpha == 0 || self.navigationController.navigationBarHidden ){
|
||||
|
||||
[UIView animateWithDuration:0.35f animations:^{
|
||||
[[UIApplication sharedApplication] setStatusBarHidden:NO];
|
||||
|
||||
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
|
||||
[self.navigationController setNavigationBarHidden:NO animated:NO];
|
||||
} else {
|
||||
self.navigationController.navigationBar.alpha = 1.0;
|
||||
}
|
||||
|
||||
[[UIApplication sharedApplication] setStatusBarHidden:NO];
|
||||
|
||||
} completion:^(BOOL finished) {
|
||||
[self fitImageViewFrame];
|
||||
|
||||
}];
|
||||
} else {
|
||||
[UIView animateWithDuration:0.35f animations:^{
|
||||
[[UIApplication sharedApplication] setStatusBarHidden:YES];
|
||||
|
||||
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
|
||||
[self.navigationController setNavigationBarHidden:YES animated:NO];
|
||||
} else {
|
||||
self.navigationController.navigationBar.alpha = 0.0;
|
||||
}
|
||||
|
||||
[[UIApplication sharedApplication] setStatusBarHidden:YES];
|
||||
|
||||
} completion:^(BOOL finished) {
|
||||
[self fitImageViewFrame];
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user