When using ionic to develop iOS system micro-letter will have a problem, filling out the form when the keyboard will block the input box, in fact, is not a big problem, as long as the user input a word can immediately see the input box.
Unfortunately, some customers are unreasonable, he did not care about the problem, anyway, is not, so in a day of sleep suddenly awakened, think out this scheme.
I'm not going to go into the code, directly above.
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 ().
var eletop = ($ionicPosition. Offset (IELM). Top)/2
var 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);
}, "
catch (E) {}}}}}}}}
]"
)