src/video/uikit/SDL_uikitview.m
changeset 8891 7b6472f1b7ba
parent 8583 fb2933ca805f
child 8983 21f5923cfd15
equal deleted inserted replaced
8890:d9a2fa86cd97 8891:7b6472f1b7ba
   370     
   370     
   371     SDL_Rect r = view.textInputRect;
   371     SDL_Rect r = view.textInputRect;
   372     int height = view.keyboardHeight;
   372     int height = view.keyboardHeight;
   373     int offsetx = 0;
   373     int offsetx = 0;
   374     int offsety = 0;
   374     int offsety = 0;
       
   375     float scale = [UIScreen mainScreen].scale;
   375     if (height) {
   376     if (height) {
   376         int sw,sh;
   377         int sw,sh;
   377         SDL_GetWindowSize(window,&sw,&sh);
   378         SDL_GetWindowSize(window,&sw,&sh);
   378         int bottom = (r.y + r.h);
   379         int bottom = (r.y + r.h);
   379         int kbottom = sh - height;
   380         int kbottom = sh - height;
   390         int tmp = offsetx; offsetx = offsety; offsety = tmp;
   391         int tmp = offsetx; offsetx = offsety; offsety = tmp;
   391     }
   392     }
   392     if (ui_orient == UIInterfaceOrientationPortraitUpsideDown) {
   393     if (ui_orient == UIInterfaceOrientationPortraitUpsideDown) {
   393         offsety = -offsety;
   394         offsety = -offsety;
   394     }
   395     }
   395     if ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)]) {
   396 
   396         float scale = [UIScreen mainScreen].scale;
   397     offsetx /= scale;
   397         offsetx /= scale;
   398     offsety /= scale;
   398         offsety /= scale;
   399 
   399     }
       
   400     view.frame = CGRectMake(offsetx,offsety,view.frame.size.width,view.frame.size.height);
   400     view.frame = CGRectMake(offsetx,offsety,view.frame.size.width,view.frame.size.height);
   401 }
   401 }
   402 
   402 
   403 void _uikit_keyboard_set_height(int height) {
   403 void _uikit_keyboard_set_height(int height) {
   404     SDL_uikitview *view = getWindowView(SDL_GetFocusWindow());
   404     SDL_uikitview *view = getWindowView(SDL_GetFocusWindow());
   422                         height = keyboardSize.height;
   422                         height = keyboardSize.height;
   423                         UIInterfaceOrientation ui_orient = [[UIApplication sharedApplication] statusBarOrientation];
   423                         UIInterfaceOrientation ui_orient = [[UIApplication sharedApplication] statusBarOrientation];
   424                         if (ui_orient == UIInterfaceOrientationLandscapeRight || ui_orient == UIInterfaceOrientationLandscapeLeft) {
   424                         if (ui_orient == UIInterfaceOrientationLandscapeRight || ui_orient == UIInterfaceOrientationLandscapeLeft) {
   425                             height = keyboardSize.width;
   425                             height = keyboardSize.width;
   426                         }
   426                         }
   427                         if ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)]) {
   427                         height *= [UIScreen mainScreen].scale;
   428                             height *= [UIScreen mainScreen].scale;
       
   429                         }
       
   430                         _uikit_keyboard_set_height(height);
   428                         _uikit_keyboard_set_height(height);
   431                     }
   429                     }
   432      ];
   430      ];
   433     [center addObserverForName:UIKeyboardDidHideNotification
   431     [center addObserverForName:UIKeyboardDidHideNotification
   434                         object:nil
   432                         object:nil