How can ionic block the input box when developing WeChat on ios system (Keyboard pop-up problem)? ionicios

Source: Internet
Author: User

How to Use ionic to block the input box when developing ios system (Keyboard pop-up problem), ionicios

When developing IOS systems using ionic, there will be an annoyance. when filling out the form, the keyboard will block the input box, which is not a big problem, you can see the input box immediately after entering a word.

It is a pity that some customers do not care about this problem, but they do not. So they suddenly woke up and came up with this solution when they went to bed one day.

I will not elaborate on the code.

angular.module('MyApp').directive('focusInput', ['$ionicScrollDelegate', '$window', '$timeout', '$ionicPosition', function ($ionicScrollDelegate, $window, $timeout, $ionicPosition) {return {restrict: 'A',scope: false,link: function ($scope, iElm, iAttrs, controller) {if (ionic.Platform.isIOS()) {iElm.on('focus', function () {var top = $ionicScrollDelegate.getScrollPosition().top;var eleTop = ($ionicPosition.offset(iElm).top) / 2var realTop = eleTop + top;$timeout(function () {if (!$scope.$last) {$ionicScrollDelegate.scrollTo(0,realTop);} else {try {var aim = angular.element(document).find('.scroll')aim.css('transform', 'translate3d(0px,' + '-' + realTop + 'px, 0px) scale(1)');$timeout(function () {iElm[0].focus();console.log(2);}, 100)} catch (e) {}}}, 500)})}}}}])

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.