Eva*_*van 11 iphone xcode objective-c ios cordova
我正在使用Cordova 2.2为IOS构建PhoneGap应用程序.当我调用我编写的本机obj-c插件来显示MFMessageComposeViewController时,我遇到了一些奇怪的行为.
安装很简单 - 我有连接到UI元素的轻敲事件,按下时,会使我的PhoneGap插件调用,它传递一个号码和短信,然后显示MFMessageComposeViewController与参数预填充.
我的javascript看起来像这样:
$(document).bind('deviceready', function(){
$(".theButton").tap(function(){
cordova.exec(function(){}, function() {}, "PhoneGapSms", "SendSms", [db.getItem("profile_sms"), db.getItem("profile_emergency")]);
});
});
Run Code Online (Sandbox Code Playgroud)
我的obj-c代码看起来像这样:
- (void)SendSms:(CDVInvokedUrlCommand*)command
{
CDVInvokedUrlCommand* myCommand = command;
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
NSString* body = [command.arguments objectAtIndex:0];
NSString* toRecipientsString = [command.arguments objectAtIndex:1];
if(body != nil)
picker.body = body;
if(toRecipientsString != nil)
[picker setRecipients:[ toRecipientsString componentsSeparatedByString:@","]];
picker.messageComposeDelegate = self;
[self.viewController presentModalViewController:picker animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[picker release];
}
Run Code Online (Sandbox Code Playgroud)
总而言之,非常简单的东西.
我的问题是:
当我的iPhone 插入我的Mac并且应用程序从XCode运行时,Message Composer叠加层显示效果很好,我的值已预先填充.插入XCode时,下图显示SMS界面正常:

当我的iPhone 从我的Mac上拔下,并且应用程序从弹簧板上运行时,叠加层向上滑动,键盘开始向上滑动,然后立即向下滑动 - 无法键入或发送消息.这是没有连接到Mac/Xcode时的样子 - 键盘开始向上滑动然后立即向下滑动(〜<1秒),留下以下界面:

我不能为我的生活弄清楚什么会导致键盘在没有从XCode运行时隐藏,但是当它运行时效果非常好.
有没有办法"强迫"键盘显示,或者可能将整个modalviewcontroller作为第一响应者以某种形式或方式?
任何建议表示赞赏!
编辑:
如果单击联系区域,键盘将再次出现
您必须添加MessageUI.framework到您的 Xcode 项目并包含
#import <MessageUI/MessageUI.h>在你的头文件中。
尝试这个代码可能对你有帮助..
[self presentModalViewController:picker animated:YES];
//[self becomeFirstResponder];//try picker also instead of self
Run Code Online (Sandbox Code Playgroud)
另请参阅以下教程并查看演示..
我希望这对你有帮助...
| 归档时间: |
|
| 查看次数: |
1468 次 |
| 最近记录: |