scroll view update upon orientation change
This commit is contained in:
1 parent
00d89f12e8
commit
c72accb3cb
3 files changed
+35
-15
No files matched your search
@@ -35,7 +35,7 @@ static NSString* DB_NAME = @"Limelight_iOS.sqlite";
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
|
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
|
||||||
return UIInterfaceOrientationMaskLandscape;
|
return UIInterfaceOrientationMaskAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#if !TARGET_OS_TV
|
#if !TARGET_OS_TV
|
||||||
@property (weak, nonatomic) IBOutlet UIBarButtonItem *upButton;
|
@property (weak, nonatomic) IBOutlet UIBarButtonItem *upButton;
|
||||||
@property (nonatomic, assign) bool settingsExpandedInStreamView;
|
@property (nonatomic, assign) bool settingsExpandedInStreamView;
|
||||||
|
@property (nonatomic, assign) bool isInHostView;
|
||||||
|
|
||||||
-(void)simulateSettingsButtonPress;
|
-(void)simulateSettingsButtonPress;
|
||||||
-(void)reloadStreamConfig;
|
-(void)reloadStreamConfig;
|
||||||
|
|||||||
@@ -300,7 +300,6 @@ static NSMutableSet* hostList;
|
|||||||
// when at the host selection view.
|
// when at the host selection view.
|
||||||
[self.navigationController.view removeGestureRecognizer:_menuRecognizer];
|
[self.navigationController.view removeGestureRecognizer:_menuRecognizer];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[_appManager stopRetrieving];
|
[_appManager stopRetrieving];
|
||||||
_showHiddenApps = NO;
|
_showHiddenApps = NO;
|
||||||
_selectedHost = nil;
|
_selectedHost = nil;
|
||||||
@@ -308,7 +307,8 @@ static NSMutableSet* hostList;
|
|||||||
|
|
||||||
[self updateTitle];
|
[self updateTitle];
|
||||||
[self disableUpButton];
|
[self disableUpButton];
|
||||||
|
self.isInHostView = true; // setting flag
|
||||||
|
[self reloadScrollHostView]; // host view must be reloaded here
|
||||||
[self.collectionView reloadData];
|
[self.collectionView reloadData];
|
||||||
[self.view addSubview:hostScrollView];
|
[self.view addSubview:hostScrollView];
|
||||||
}
|
}
|
||||||
@@ -347,6 +347,7 @@ static NSMutableSet* hostList;
|
|||||||
[self updateTitle];
|
[self updateTitle];
|
||||||
[self enableUpButton];
|
[self enableUpButton];
|
||||||
[self disableNavigation];
|
[self disableNavigation];
|
||||||
|
self.isInHostView = false;
|
||||||
|
|
||||||
#if TARGET_OS_TV
|
#if TARGET_OS_TV
|
||||||
// Intercept the menu key to go back to the host page
|
// Intercept the menu key to go back to the host page
|
||||||
@@ -904,8 +905,12 @@ static NSMutableSet* hostList;
|
|||||||
// Convert the delay into a dispatch_time_t value
|
// Convert the delay into a dispatch_time_t value
|
||||||
dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
|
dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
|
||||||
// Perform some task after the delay
|
// Perform some task after the delay
|
||||||
|
CGFloat screenWidthInPoints = CGRectGetWidth([[UIScreen mainScreen] bounds]);
|
||||||
|
|
||||||
dispatch_after(delayTime, dispatch_get_main_queue(), ^{// Code to execute after the delay
|
dispatch_after(delayTime, dispatch_get_main_queue(), ^{// Code to execute after the delay
|
||||||
[self swapResolutionWidthHeightAccordingly];
|
[self swapResolutionWidthHeightAccordingly];
|
||||||
|
if(self.isInHostView) [self reloadScrollHostView]; // here is a flag for judging whether to reload host view after orientation change.
|
||||||
|
self->recordedScreenWidth = screenWidthInPoints; // kind of obselete, but i keep this in the code.
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1018,7 +1023,8 @@ static NSMutableSet* hostList;
|
|||||||
//[OrientationHelper updateOrientationToLandscape];
|
//[OrientationHelper updateOrientationToLandscape];
|
||||||
[self attachWaterMark];
|
[self attachWaterMark];
|
||||||
#if !TARGET_OS_TV
|
#if !TARGET_OS_TV
|
||||||
_settingsExpandedInStreamView = false; // init this flag
|
self.settingsExpandedInStreamView = false; // init this flag
|
||||||
|
self.isInHostView = true;
|
||||||
|
|
||||||
// Set the side bar button action. When it's tapped, it'll show the sidebar.
|
// Set the side bar button action. When it's tapped, it'll show the sidebar.
|
||||||
[_settingsButton setTarget:self.revealViewController];
|
[_settingsButton setTarget:self.revealViewController];
|
||||||
@@ -1074,8 +1080,23 @@ static NSMutableSet* hostList;
|
|||||||
|
|
||||||
_boxArtCache = [[NSCache alloc] init];
|
_boxArtCache = [[NSCache alloc] init];
|
||||||
|
|
||||||
|
recordedScreenWidth = CGRectGetWidth([[UIScreen mainScreen] bounds]);
|
||||||
hostScrollView = [[ComputerScrollView alloc] init];
|
hostScrollView = [[ComputerScrollView alloc] init];
|
||||||
|
[self reloadScrollHostView];
|
||||||
|
|
||||||
|
//if([SettingsViewController isLandscapeNow] != _streamConfig.width > _streamConfig.height)
|
||||||
|
//[self simulateSettingsButtonPress]; //force expand setting view if orientation changed since last quit from app.
|
||||||
|
//[self simulateSettingsButtonPress]; //force expand setting view if orientation changed since last quit from app.
|
||||||
|
[self swapResolutionWidthHeightAccordingly];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
-(void)handleRealOrientationChange{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)reloadScrollHostView{
|
||||||
|
[hostScrollView removeFromSuperview];
|
||||||
CGFloat screenWidthInPoints = CGRectGetWidth([[UIScreen mainScreen] bounds]);
|
CGFloat screenWidthInPoints = CGRectGetWidth([[UIScreen mainScreen] bounds]);
|
||||||
CGFloat screenHeightInPoints = CGRectGetHeight([[UIScreen mainScreen] bounds]);
|
CGFloat screenHeightInPoints = CGRectGetHeight([[UIScreen mainScreen] bounds]);
|
||||||
|
|
||||||
@@ -1095,14 +1116,14 @@ static NSMutableSet* hostList;
|
|||||||
|
|
||||||
self.collectionView.delaysContentTouches = NO;
|
self.collectionView.delaysContentTouches = NO;
|
||||||
self.collectionView.allowsMultipleSelection = NO;
|
self.collectionView.allowsMultipleSelection = NO;
|
||||||
#if !TARGET_OS_TV
|
#if !TARGET_OS_TV
|
||||||
self.collectionView.multipleTouchEnabled = NO;
|
self.collectionView.multipleTouchEnabled = NO;
|
||||||
#else
|
#else
|
||||||
// This is the only way to get long press events on a UICollectionViewCell :(
|
// This is the only way to get long press events on a UICollectionViewCell :(
|
||||||
UILongPressGestureRecognizer* cellLongPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleCollectionViewLongPress:)];
|
UILongPressGestureRecognizer* cellLongPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleCollectionViewLongPress:)];
|
||||||
cellLongPress.delaysTouchesBegan = YES;
|
cellLongPress.delaysTouchesBegan = YES;
|
||||||
[self.collectionView addGestureRecognizer:cellLongPress];
|
[self.collectionView addGestureRecognizer:cellLongPress];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[self retrieveSavedHosts];
|
[self retrieveSavedHosts];
|
||||||
_discMan = [[DiscoveryManager alloc] initWithHosts:[hostList allObjects] andCallback:self];
|
_discMan = [[DiscoveryManager alloc] initWithHosts:[hostList allObjects] andCallback:self];
|
||||||
@@ -1114,20 +1135,17 @@ static NSMutableSet* hostList;
|
|||||||
[self updateTitle];
|
[self updateTitle];
|
||||||
[self.view addSubview:hostScrollView];
|
[self.view addSubview:hostScrollView];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//if([SettingsViewController isLandscapeNow] != _streamConfig.width > _streamConfig.height)
|
|
||||||
//[self simulateSettingsButtonPress]; //force expand setting view if orientation changed since last quit from app.
|
|
||||||
//[self simulateSettingsButtonPress]; //force expand setting view if orientation changed since last quit from app.
|
|
||||||
[self swapResolutionWidthHeightAccordingly];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-(void)swapResolutionWidthHeightAccordingly{
|
-(void)swapResolutionWidthHeightAccordingly{
|
||||||
DataManager* dataMan = [[DataManager alloc] init];
|
DataManager* dataMan = [[DataManager alloc] init];
|
||||||
Settings *currentSettings = [dataMan retrieveSettings];
|
Settings *currentSettings = [dataMan retrieveSettings];
|
||||||
CGFloat screenWidthInPoints = CGRectGetWidth([[UIScreen mainScreen] bounds]);
|
CGFloat screenWidthInPoints = CGRectGetWidth([[UIScreen mainScreen] bounds]);
|
||||||
CGFloat screenHeightInPoints = CGRectGetHeight([[UIScreen mainScreen] bounds]);
|
CGFloat screenHeightInPoints = CGRectGetHeight([[UIScreen mainScreen] bounds]);
|
||||||
bool needSwap = ((currentSettings.width.floatValue - currentSettings.height.floatValue) * (screenWidthInPoints - screenHeightInPoints)) < 0;
|
bool needSwap = ((currentSettings.width.floatValue - currentSettings.height.floatValue) * (screenWidthInPoints - screenHeightInPoints)) < 0; //update the current resolution accordingly
|
||||||
NSLog(@"need to swap width & height: %d", needSwap);
|
NSLog(@"need to swap width & height: %d", needSwap);
|
||||||
if(needSwap){
|
if(needSwap){
|
||||||
CGFloat tmpLength = currentSettings.width.floatValue;
|
CGFloat tmpLength = currentSettings.width.floatValue;
|
||||||
@@ -1235,7 +1253,8 @@ static NSMutableSet* hostList;
|
|||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
[[self revealViewController] setPrimaryViewController:self];
|
[[self revealViewController] setPrimaryViewController:self];
|
||||||
recordedScreenWidth = CGRectGetWidth([[UIScreen mainScreen] bounds]); // Get the screen's bounds (in points), for force expand setting view
|
recordedScreenWidth = CGRectGetWidth([[UIScreen mainScreen] bounds]); // Get the screen's bounds (in points), update recorded screen width
|
||||||
|
self.isInHostView = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[self.navigationController setNavigationBarHidden:NO animated:YES];
|
[self.navigationController setNavigationBarHidden:NO animated:YES];
|
||||||
|
|||||||
Reference in new issue
Block a user