mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-17 06:01:13 +00:00
Allow panning to the bottom of the screen when the keyboard appears
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
StreamView *_streamView;
|
StreamView *_streamView;
|
||||||
UIScrollView *_scrollView;
|
UIScrollView *_scrollView;
|
||||||
BOOL _userIsInteracting;
|
BOOL _userIsInteracting;
|
||||||
|
CGSize _keyboardSize;
|
||||||
|
|
||||||
#if !TARGET_OS_TV
|
#if !TARGET_OS_TV
|
||||||
UIScreenEdgePanGestureRecognizer *_exitSwipeRecognizer;
|
UIScreenEdgePanGestureRecognizer *_exitSwipeRecognizer;
|
||||||
@@ -108,6 +109,8 @@
|
|||||||
#else
|
#else
|
||||||
_exitSwipeRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(edgeSwiped)];
|
_exitSwipeRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(edgeSwiped)];
|
||||||
_exitSwipeRecognizer.edges = UIRectEdgeLeft;
|
_exitSwipeRecognizer.edges = UIRectEdgeLeft;
|
||||||
|
_exitSwipeRecognizer.delaysTouchesBegan = NO;
|
||||||
|
_exitSwipeRecognizer.delaysTouchesEnded = NO;
|
||||||
|
|
||||||
[self.view addGestureRecognizer:_exitSwipeRecognizer];
|
[self.view addGestureRecognizer:_exitSwipeRecognizer];
|
||||||
#endif
|
#endif
|
||||||
@@ -147,6 +150,16 @@
|
|||||||
name: UIApplicationDidEnterBackgroundNotification
|
name: UIApplicationDidEnterBackgroundNotification
|
||||||
object: nil];
|
object: nil];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver: self
|
||||||
|
selector: @selector(keyboardWillShow:)
|
||||||
|
name: UIKeyboardWillShowNotification
|
||||||
|
object: nil];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver: self
|
||||||
|
selector: @selector(keyboardWillHide:)
|
||||||
|
name: UIKeyboardWillHideNotification
|
||||||
|
object: nil];
|
||||||
|
|
||||||
// Only enable scroll and zoom in absolute touch mode
|
// Only enable scroll and zoom in absolute touch mode
|
||||||
if (_settings.absoluteTouchMode) {
|
if (_settings.absoluteTouchMode) {
|
||||||
_scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
|
_scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
|
||||||
@@ -190,6 +203,28 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)keyboardWillShow:(NSNotification *)notification {
|
||||||
|
_keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
|
||||||
|
|
||||||
|
[UIView animateWithDuration:0.3 animations:^{
|
||||||
|
CGRect frame = self->_scrollView.frame;
|
||||||
|
frame.size.height -= self->_keyboardSize.height;
|
||||||
|
self->_scrollView.frame = frame;
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)keyboardWillHide:(NSNotification *)notification {
|
||||||
|
// NOTE: UIKeyboardFrameEndUserInfoKey returns a different keyboard size
|
||||||
|
// than UIKeyboardFrameBeginUserInfoKey, so it's unsuitable for use here
|
||||||
|
// to undo the changes made by keyboardWillShow.
|
||||||
|
|
||||||
|
[UIView animateWithDuration:0.3 animations:^{
|
||||||
|
CGRect frame = self->_scrollView.frame;
|
||||||
|
frame.size.height += self->_keyboardSize.height;
|
||||||
|
self->_scrollView.frame = frame;
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)updateStatsOverlay {
|
- (void)updateStatsOverlay {
|
||||||
NSString* overlayText = [self->_streamMan getStatsOverlayText];
|
NSString* overlayText = [self->_streamMan getStatsOverlayText];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user