无法在IOS中的离子1应用页面中复制<p>标记内的文本

时间:2017-10-24 10:19:52

标签: javascript ios angularjs ionic-framework

我为IOS和Android平台创建了一个ionic-1应用程序。在其中一个视图中,我显示了一些移动号码,这些号码位于<p>标记中。当用户单击并保留该号码以进行选择时,应复制该号码。它在android中运行良好,但在IOS中运行不正常。我使用了很少的解决方案,例如user-select: text;user-select: auto;我如何才能在IOS中执行此操作?

1 个答案:

答案 0 :(得分:0)

尝试此解决方案

angular.module('ionicApp', ['ionic'])

.controller('MyCtrl', function($scope) {
  stop_browser_behavior: false
  
self.touchStart = function(e) {
  self.startCoordinates = getPointerCoordinates(e);

  if ( ionic.tap.ignoreScrollStart(e) ) {
    return;
  }

  if( ionic.tap.containsOrIsTextInput(e.target) ) {
    // do not start if the target is a text input
    // if there is a touchmove on this input, then we can start the scroll
    self.__hasStarted = false;
    return;
  }

  self.__isSelectable = true;
  self.__enableScrollY = true;
  self.__hasStarted = true;
  self.doTouchStart(e.touches, e.timeStamp);
  // e.preventDefault();
};
});
body {
  cursor: url('https://ionicframework.com/img/finger.png'), auto;
}

ion-content{
  overflow-scroll: true;
}

.scroll-content {
  -webkit-user-select: auto !important;
  -moz-user-select: auto !important;
  -ms-user-select: auto !important;
  user-select: auto !important;}

.selectable {
  -webkit-user-select: auto;
}
<html ng-app="ionicApp">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    
    <title>Ionic Template</title>

    <link href="https://code.ionicframework.com/1.0.0-beta.4/css/ionic.css" rel="stylesheet">
    <script src="https://code.ionicframework.com/1.0.0-beta.4/js/ionic.bundle.js"></script>
  </head>
  <body ng-controller="MyCtrl">
    
    <ion-header-bar class="bar-positive">

      <h1 class="title">{{myTitle}}</h1>

    </ion-header-bar>

    <ion-content padding="true" overflow-scroll='true'>
      <h2>Content</h2>
      <div class='selectable'>
        
        Text that users should be able to select and copy.
      </div>
    </ion-content>
    
    
  </body>
</html>