Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #152 from owncloud/OC-4732_ios8_issues_ipad
Browse files Browse the repository at this point in the history
Oc 4732 ios8 issues ipad
  • Loading branch information
javiergonzper committed Sep 2, 2014
2 parents 105b541 + 7cff354 commit 38a7f70
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ typedef enum _MGSplitViewDividerStyle {
- (IBAction)toggleMasterView:(id)sender; // toggles display of the master view in the current orientation.
- (IBAction)showMasterPopover:(id)sender; // shows the master view in a popover spawned from the provided barButtonItem, if it's currently hidden.
- (void)notePopoverDismissed; // should rarely be needed, because you should not change the popover's delegate. If you must, then call this when it's dismissed.

- (void) removeThePopover;
// Conveniences for you, because I care.
- (BOOL)isShowingMaster;
- (void)setSplitPosition:(float)posn animated:(BOOL)animate; // Allows for animation of splitPosition changes. The property's regular setter is not animated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ - (NSString *)nameOfInterfaceOrientation:(UIInterfaceOrientation)theOrientation

- (BOOL)isLandscape
{
return UIInterfaceOrientationIsLandscape(self.interfaceOrientation);
return UIInterfaceOrientationIsLandscape([self getTheInterfaceOrientation]);
}


Expand All @@ -90,13 +90,26 @@ - (BOOL)shouldShowMasterForInterfaceOrientation:(UIInterfaceOrientation)theOrien

- (BOOL)shouldShowMaster
{
return [self shouldShowMasterForInterfaceOrientation:self.interfaceOrientation];
return [self shouldShowMasterForInterfaceOrientation:[self getTheInterfaceOrientation]];
}


- (BOOL)isShowingMaster
{
return [self shouldShowMaster] && self.masterViewController && self.masterViewController.view && ([self.masterViewController.view superview] == self.view);
BOOL showingMaster = NO;

if ([self shouldShowMaster] && self.masterViewController && self.masterViewController.view && ([self.masterViewController.view superview] == self.view)) {
showingMaster = YES;
}

return showingMaster;

}

- (UIInterfaceOrientation)getTheInterfaceOrientation{

return [[UIApplication sharedApplication] statusBarOrientation];

}


Expand Down Expand Up @@ -176,12 +189,6 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
//Only for ios 6
- (BOOL)shouldAutorotate {

UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];

if (orientation==UIInterfaceOrientationPortrait) {

}

return YES;
}

Expand All @@ -194,8 +201,10 @@ - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrie

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{

[self.masterViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[self.detailViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];

}


Expand All @@ -212,7 +221,8 @@ - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInte

// Re-tile views.
_reconfigurePopup = YES;
[self layoutSubviewsForInterfaceOrientation:toInterfaceOrientation withAnimation:YES];
[self layoutSubviews];


AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication]delegate];
[app.detailViewController adjustGalleryScrollView];
Expand Down Expand Up @@ -241,9 +251,40 @@ - (void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrie
}


#pragma mark - iOS 8 rotation method.

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {

NSTimeInterval duration = 0.0;

// willRotateToInterfaceOrientation code goes here
[self willRotateToInterfaceOrientation:[self getTheInterfaceOrientation] duration:duration];

if(![self isShowingMaster] && ![self isLandscape]){
_reconfigurePopup = YES;
[self reconfigureForMasterInPopover:NO];
[self layoutSubviews];
}


[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
// willAnimateRotationToInterfaceOrientation code goes here
[self willAnimateRotationToInterfaceOrientation:[self getTheInterfaceOrientation] duration:duration];

} completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
// didRotateFromInterfaceOrientation goes here (nothing for now)
[self didRotateFromInterfaceOrientation:[self getTheInterfaceOrientation]];
}];


[super viewWillTransitionToSize: size withTransitionCoordinator: coordinator];
}


- (CGSize)splitViewSizeForOrientation:(UIInterfaceOrientation)theOrientation
{
UIScreen *screen = [UIScreen mainScreen];
UIScreen *screen = [UIScreen mainScreen];

CGRect fullScreenRect = screen.bounds; // always implicitly in Portrait orientation.
CGRect appFrame = screen.applicationFrame;

Expand All @@ -256,7 +297,7 @@ - (CGSize)splitViewSizeForOrientation:(UIInterfaceOrientation)theOrientation
float height = fullScreenRect.size.height;

// Correct for orientation.
if (UIInterfaceOrientationIsLandscape(theOrientation)) {
if (UIInterfaceOrientationIsLandscape(theOrientation) && !IS_IOS8) {
width = height;
height = fullScreenRect.size.width;
}
Expand All @@ -278,7 +319,7 @@ - (void)layoutSubviewsForInterfaceOrientation:(UIInterfaceOrientation)theOrienta
if (_reconfigurePopup) {
[self reconfigureForMasterInPopover:![self shouldShowMasterForInterfaceOrientation:theOrientation]];
}
// Layout the master, detail and divider views appropriately, adding/removing subviews as needed.
// First obtain relevant geometry.
CGSize fullSize = [self splitViewSizeForOrientation:theOrientation];
Expand Down Expand Up @@ -521,13 +562,13 @@ - (void)layoutSubviewsForInterfaceOrientation:(UIInterfaceOrientation)theOrienta

- (void)layoutSubviewsWithAnimation:(BOOL)animate
{
[self layoutSubviewsForInterfaceOrientation:self.interfaceOrientation withAnimation:animate];
[self layoutSubviewsForInterfaceOrientation:[self getTheInterfaceOrientation] withAnimation:animate];
}


- (void)layoutSubviews
{
[self layoutSubviewsForInterfaceOrientation:self.interfaceOrientation withAnimation:YES];
[self layoutSubviewsForInterfaceOrientation:[self getTheInterfaceOrientation] withAnimation:YES];
}


Expand Down Expand Up @@ -622,7 +663,11 @@ - (void)reconfigureForMasterInPopover:(BOOL)inPopover
}

//Define the size of the popOver
_hiddenPopoverController.popoverContentSize=CGSizeMake(320, [[UIScreen mainScreen] bounds].size.height);


UIScreen *screen = [UIScreen mainScreen];

_hiddenPopoverController.popoverContentSize=CGSizeMake(320, screen.bounds.size.height);

// Inform delegate of this state of affairs.
if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:willHideViewController:withBarButtonItem:forPopoverController:)]) {
Expand All @@ -633,8 +678,12 @@ - (void)reconfigureForMasterInPopover:(BOOL)inPopover
}

} else if (!inPopover && _hiddenPopoverController && _barButtonItem) {
// I know this looks strange, but it fixes a bizarre issue with UIPopoverController leaving masterViewController's views in disarray.
[_hiddenPopoverController presentPopoverFromRect:CGRectZero inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];

if (!IS_IOS8) {
// I know this looks strange, but it fixes a bizarre issue with UIPopoverController leaving masterViewController's views in disarray.
[_hiddenPopoverController presentPopoverFromRect:CGRectZero inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];
}


// Remove master from popover and destroy popover, if it exists.
[_hiddenPopoverController dismissPopoverAnimated:NO];
Expand All @@ -653,10 +702,11 @@ - (void)reconfigureForMasterInPopover:(BOOL)inPopover
_barButtonItem = nil;

// Move master view.
UIView *masterView = self.masterViewController.view;
if (masterView && masterView.superview != self.view) {
[masterView removeFromSuperview];
}
UIView *masterView = self.masterViewController.view;
if (masterView && masterView.superview != self.view) {
[masterView removeFromSuperview];
}

}
}

Expand Down Expand Up @@ -715,8 +765,7 @@ - (IBAction)toggleSplitOrientation:(id)sender
}


- (IBAction)toggleMasterBeforeDetail:(id)sender
{
- (IBAction)toggleMasterBeforeDetail:(id)sender {
BOOL showingMaster = [self isShowingMaster];
if (showingMaster) {
if (_cornerViews) {
Expand All @@ -735,28 +784,32 @@ - (IBAction)toggleMasterBeforeDetail:(id)sender
}
}

- (void) removeThePopover {

if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
[_hiddenPopoverController dismissPopoverAnimated:NO];
}
}

- (IBAction)toggleMasterView:(id)sender
{
if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
[_hiddenPopoverController dismissPopoverAnimated:NO];
}

- (IBAction)toggleMasterView:(id)sender {
if (![self isShowingMaster]) {
// We're about to show the master view. Ensure it's in place off-screen to be animated in.
_reconfigurePopup = YES;
[self reconfigureForMasterInPopover:NO];
[self layoutSubviews];
}
}

// This action functions on the current primary orientation; it is independent of the other primary orientation.
[UIView beginAnimations:@"toggleMaster" context:nil];
if (self.isLandscape) {
self.showsMasterInLandscape = !_showsMasterInLandscape;

self.showsMasterInLandscape = !_showsMasterInLandscape;
} else {
self.showsMasterInPortrait = !_showsMasterInPortrait;
}
[UIView commitAnimations];


}


Expand Down Expand Up @@ -908,7 +961,8 @@ - (void)setSplitPosition:(float)posn
// Check to see if delegate wishes to constrain the position.
float newPosn = posn;
BOOL constrained = NO;
CGSize fullSize = [self splitViewSizeForOrientation:self.interfaceOrientation];
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
CGSize fullSize = [self splitViewSizeForOrientation:orientation];
if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:constrainSplitPosition:splitViewSize:)]) {
newPosn = [_delegate splitViewController:self constrainSplitPosition:newPosn splitViewSize:fullSize];
constrained = YES; // implicitly trust delegate's response.
Expand Down
79 changes: 57 additions & 22 deletions Owncloud iOs Client/Files/Preview/DetailView/DetailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ - (void) openGalleryFileOnUpdatingProcess: (BOOL) isUpdatingProcess {
* We use this feature for example to charge Help page.
*/

- (void)finishLinkLoad{
- (void)finishLinkLoad {
[_titleLabel setText:_linkTitle];
}

Expand Down Expand Up @@ -1901,29 +1901,37 @@ - (IBAction)toggleMasterView:(id)sender {
[_galleryView prepareScrollViewBeforeTheRotation];
}

//Tell to splitController to extend the detailview
[splitController toggleMasterView:sender];
[splitController removeThePopover];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{

//Tell to splitController to extend the detailview
[splitController toggleMasterView:sender];


//Change the global flag
if (_isExtend==NO) {
//Set the constraint
_leftMarginTitleLabelConstraint.constant = 92;
_isExtend = YES;
} else {
//Set the constraint
_leftMarginTitleLabelConstraint.constant = 62;
_isExtend = NO;
}

//Managed the objects of landscape view.
[self landscapeView];

//If galleryView charged indicated adjust the scroll view
if (_galleryView) {
_isExtending = YES;
[self adjustGalleryScrollView];
}


});

//Change the global flag
if (_isExtend==NO) {
//Set the constraint
_leftMarginTitleLabelConstraint.constant = 92;
_isExtend = YES;
} else {
//Set the constraint
_leftMarginTitleLabelConstraint.constant = 62;
_isExtend = NO;
}

//Managed the objects of landscape view.
[self landscapeView];

//If galleryView charged indicated adjust the scroll view
if (_galleryView) {
_isExtending = YES;
[self adjustGalleryScrollView];
}

}

Expand Down Expand Up @@ -2008,6 +2016,33 @@ - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceO

[self showPopover];
}

#pragma mark - iOS 8 rotation method.

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {

UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

NSTimeInterval duration = 0.5;

// willRotateToInterfaceOrientation code goes here
[self willRotateToInterfaceOrientation:orientation duration:duration];

[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
// willAnimateRotationToInterfaceOrientation code goes here
[self willAnimateRotationToInterfaceOrientation:orientation duration:duration];


} completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
// didRotateFromInterfaceOrientation goes here (nothing for now)
[self didRotateFromInterfaceOrientation:orientation];

}];


[super viewWillTransitionToSize: size withTransitionCoordinator: coordinator];
}

/*
* Method that tell to galleryView to adjust the scroll view after the rotation
*/
Expand Down
3 changes: 2 additions & 1 deletion Owncloud iOs Client/Utils/SystemConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
//

#define IS_IOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
#define IS_IOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] == 7)
#define IS_IOS8 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_PORTRAIT (([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait) || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown)

0 comments on commit 38a7f70

Please sign in to comment.