2014-10-09 47 views
1

的iOS 8 jQuery Mobile的1.4科尔多瓦3.6.3任何模拟器,任何物理真实设备的iOS 8 jQuery Mobile的1.4.4输入键盘没有隐瞒页脚菜单了

问题隐藏页脚当键盘出现打字到表单字段

previous solution在iOS7上表现很好,当您点击输入元素时现在看起来不错,但是如果您滚动表单,页脚会出现(固定到页面)与其他一些输入字段重叠。

+0

iOS8,jQuery Mobile 1.4.4,cordova 3.6.3 - 这里没有问题。键盘打开时没有跳起页脚。 – Sithys 2014-10-09 15:47:04

+0

我同意没有跳跃,但如果你有一个长表单,并且你滚动页面,你会发现页脚出现。 – sasha 2014-10-10 04:02:29

+0

我测试你的“bug”的表单是一个包含15个输入字段和3个选定区域的注册表单。没有跳跃或即将到来的页脚 – Sithys 2014-10-10 07:20:31

回答

0

找到解决方案!

的iOS

必须编辑CDVNotification.m和CDVNotification.h在src文件夹这里描述的org.apache.cordova.dialogs插件:add properties and methods to CDVnotification

既然不明确放在哪里新生产线,这是在CDVnotification.h新代码

#import <Foundation/Foundation.h> 
#import <UIKit/UIKit.h> 
#import <AudioToolbox/AudioServices.h> 
#import <Cordova/CDVPlugin.h> 

@interface CDVNotification : CDVPlugin <UIAlertViewDelegate>{} 

@property (strong) NSString* keyboardShowcallbackId; 
@property (strong) NSString* keyboardHidecallbackId; 

- (void)alert:(CDVInvokedUrlCommand*)command; 
- (void)confirm:(CDVInvokedUrlCommand*)command; 
- (void)prompt:(CDVInvokedUrlCommand*)command; 
- (void)beep:(CDVInvokedUrlCommand*)command; 

- (void)keyboardShow:(CDVInvokedUrlCommand*)command; 
- (void)keyboardHide:(CDVInvokedUrlCommand*)command; 

@end 

@interface CDVAlertView : UIAlertView {} 
@property (nonatomic, copy) NSString* callbackId; 

@end 

那么这里是我贴在CDVNotification.m

新线
- (void)beep:(CDVInvokedUrlCommand*)command 
{ 
    NSNumber* count = [command.arguments objectAtIndex:0 withDefault:[NSNumber numberWithInt:1]]; 
    playBeep([count intValue]); 
} 

//Keyboard notifications. 

- (void)keyboardShow:(CDVInvokedUrlCommand*)command { 

    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil]; 

    self.keyboardShowcallbackId = command.callbackId; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardShowCallback:) 
               name:UIKeyboardWillShowNotification object:nil]; 
} 
- (void)keyboardHide:(CDVInvokedUrlCommand*)command { 
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil]; 

    self.keyboardHidecallbackId = command.callbackId; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardHideCallback:) 
               name:UIKeyboardWillHideNotification object:nil]; 
} 

- (void)keyBoardHideCallback:(NSNotification*)notification { 
    if (self.keyboardHidecallbackId) { 
     CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; 
     [result setKeepCallbackAsBool:YES]; 

     [self.commandDelegate sendPluginResult:result callbackId:self.keyboardHidecallbackId]; 
    } 
} 

- (void)keyBoardShowCallback:(NSNotification*)notification { 
    if (self.keyboardShowcallbackId) { 
     CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; 

     [result setKeepCallbackAsBool:YES]; 
     [self.commandDelegate sendPluginResult:result callbackId:self.keyboardShowcallbackId]; 
    } 
} 

@end 

@implementation CDVAlertView 

@synthesize callbackId; 

@end 

然后找到您的cordova/phonegap应用中的ondeviceready事件,并粘贴两条cordova.exec行。

onDeviceReady: function() { 
    app.receivedEvent('deviceready'); 

    navigator.splashscreen.hide(); 

}, // fine onDeviceReady 

receivedEvent: function(id) { 

    console.log('Received Event: ' + id); 

    if (isMobile.iOS()) { 

     alert("this is iOS"); // 

     cordova.exec(function(){ $("#footer").hide(); },function(){console.log("error");},"Notification","keyboardShow",[]); 

     cordova.exec(function(){ $("#footer").show(); },function(){console.log("error");},"Notification","keyboardHide",[]); 

    } else { 

     alert("this is android"); 

     document.addEventListener("showkeyboard", function(){ $("#footer").hide(); }, false); 
     document.addEventListener("hidekeyboard", function(){ $("#footer").show(); }, false); 


    } 



} 

的Android

以前的解决方案,检测窗口大小调整时,虚拟键盘上来通过CSS的JS插入代码,还是在安卓

<script type="text/javascript"> 
document.write('<style>#footer{visibility:hidden}@media(min-height:' + ($(window).height() - 10) + 'px){#footer{visibility:visible}}</style>'); 
</script> 

工作,但是我选择了

document.addEventListener("showkeyboard", function(){ $("#footer").hide(); }, false); 
document.addEventListener("hidekeyboard", function(){ $("#footer").show(); }, false); 

if Android Device。

希望它可以帮助像我这样的人挣扎,因为一个月:)!