无法<p>从 IOS 中的 ionic 1 应用程序页面复制标签内的文本



我为IOS和Android平台创建了一个ionic-1应用程序。在其中一个视图中,我正在显示一些手机号码,这些号码在<p>标签中。当用户单击并按住该号码进行选择时,它应复制该号码。它在安卓中工作正常,但在IOS中则不然。我使用过很少的解决方案,例如user-select: text;user-select: auto;如何在IOS中执行此操作?

试试这个解决方案

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>

最新更新