resize view when keyboard appears
This commit is contained in:
@@ -43,6 +43,42 @@ int t_count = 0;
|
||||
return YES;
|
||||
}
|
||||
|
||||
// Call this method somewhere in your view controller setup code.
|
||||
- (void)registerForKeyboardNotifications
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWasShown:)
|
||||
name:UIKeyboardWillShowNotification object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWillBeHidden:)
|
||||
name:UIKeyboardWillHideNotification object:nil];
|
||||
|
||||
}
|
||||
|
||||
// Called when the UIKeyboardDidShowNotification is sent.
|
||||
- (void)keyboardWasShown:(NSNotification*)aNotification
|
||||
{
|
||||
NSDictionary* info = [aNotification userInfo];
|
||||
CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
|
||||
|
||||
GLKView *view = (GLKView *)self.view;
|
||||
CGRect frame = view.frame;
|
||||
frame.size.height -= kbSize.height;
|
||||
view.frame = frame;
|
||||
App::I.resize(frame.size.width * view.contentScaleFactor,
|
||||
frame.size.height * view.contentScaleFactor);
|
||||
}
|
||||
|
||||
// Called when the UIKeyboardWillHideNotification is sent
|
||||
- (void)keyboardWillBeHidden:(NSNotification*)aNotification
|
||||
{
|
||||
CGRect frame = [[UIScreen mainScreen] bounds];
|
||||
self.view.frame = frame;
|
||||
App::I.resize(frame.size.width * self.view.contentScaleFactor,
|
||||
frame.size.height * self.view.contentScaleFactor);
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
UITouch *touch = [[event allTouches] anyObject];
|
||||
@@ -122,6 +158,7 @@ int t_count = 0;
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[self resignFirstResponder];
|
||||
[self registerForKeyboardNotifications];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
|
||||
@@ -125,7 +125,7 @@ void App::update(float dt)
|
||||
//glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
#ifndef __ANDROID__
|
||||
layout.reload();
|
||||
//layout.reload();
|
||||
#endif
|
||||
if (auto* main = layout[main_id])
|
||||
main->update(width, height, zoom);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "node_panel_stroke.h"
|
||||
#include "node_canvas.h"
|
||||
|
||||
#ifdef __OBJC__
|
||||
#if defined(__OBJC__) && defined(__IOS__)
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "GameViewController.h"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user