gpt4 book ai didi

angularjs - 使用文本区域和键盘显示 ionic 模态的正确方法

转载 作者:行者123 更新时间:2023-12-04 08:48:34 25 4
gpt4 key购买 nike

我有一个用于发送消息的模式,为了让键盘显示,我必须将焦点设置在 textarea 上。触发模态后。

HTML

  <script id="new-post.html" type="text/ng-template">
<div class="modal">
<form ng-submit="sendPost(post)">
<ion-header-bar class="bar-royal">
<button class="button button-clear button-light" ng-click="closeNewPost()">Cancel</button>
<h1 class="title">New Message</h1>
<button type="submit" class="button button-clear">Post</button>
</ion-header-bar>
<ion-content>

<div class="list">
<label class="item item-input">
<textarea class="textareas" id="postMessageInput" ng-model="$parent.post.message" placeholder="What do you want to say?" autofocus ></textarea>
</label>
</div>
</ion-content>
</form>
</div>

Controller :
$ionicModal.fromTemplateUrl('new-post.html', function(modal) {
$scope.postModal = modal;
}, {
scope: $scope,
focusFirstInput: true
});
$scope.newPost = function() {
$scope.postModal.show().then(document.getElementById('postMessageInput').focus());
};

发生的情况是模态首先向上滑动,然后键盘向上滑动。有时在模态首次显示时屏幕会闪烁。整个体验一点都不流畅。有时 textarea 甚至被推到模态标题下。

理想情况下,我希望模态与已经呈现在 View 上的键盘一起向上滑动,就好像键盘嵌入到模态中一样。这就是其他应用程序 (ios) 的工作方式。这是可能的,还是有一种标准方法可以用键盘和文本区域显示模态?

最佳答案

我通过将禁用屏幕设置为 true 来修复屏幕闪烁:

cordova.plugins.Keyboard.disableScroll(true)

Checkout Ionic Keyboard iOS Notes here

关于angularjs - 使用文本区域和键盘显示 ionic 模态的正确方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28012187/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com