大图APP
大图APP
  • 发布:2021-05-23 17:02
  • 更新:2021-05-23 17:48
  • 阅读:954

IOS var UIPasteboard = plus.ios.importClass("UIPasteboard");为 null

分类:Native.js

IOS获取下剪切板数据方法!

var UIPasteboard = plus.ios.importClass("UIPasteboard");
这个 UIPasteboard 为 null

## 获取剪切板    
var UIPasteboard  = plus.ios.importClass("UIPasteboard");    
var generalPasteboard = UIPasteboard.generalPasteboard();    
// 设置/获取文本内容:    
generalPasteboard.setValueforPasteboardType("testValue", "public.utf8-plain-text");    
var value = generalPasteboard.valueForPasteboardType("public.utf8-plain-text");   

报错

TypeError: null is not an object (evaluating 'UIPasteboard.generalPasteboard')

我看很多遇到这种问题 都是不了了之!

真的没办法了码?

标准基座+真机调试

iPhone XR IOS14.4.2

wap2app

HBuilder X 3.1.15.20210518-alpha

本地代码

sitemap.json中 "appendJs": "js/wap2app.js"加入

2021-05-23 17:02 负责人:无 分享
已邀请:
banro

banro

实测 复制粘贴你的代码,测试无误,可用

  • 大图APP (作者)

    sitemap.json中 "appendJs": "js/wap2app.js" 加入js不行

    2021-05-23 17:52

  • 大图APP (作者)

    丢 app.js 里可以

    2021-05-23 17:52

  • 6***@qq.com

    回复 大图APP: 你怎么丢进去的啊。。

    2021-06-03 10:47

  • 大图APP (作者)

    回复 6***@qq.com: wap2app坑太多,填不完已经放弃了,现在项目正在转uni-app

    2021-06-03 10:57

  • 6***@qq.com

    回复 大图APP: 那你在这个复制是怎么解决的啊。。。

    2021-06-03 11:01

  • 大图APP (作者)

    回复 6***@qq.com: 安卓端正常获取,区分一下 ios,在app.js onShow 里自动获取保存到plus.storage 里,需要取值地方 从 plus.storage获取。

    2021-06-03 11:09

  • 6***@qq.com

    回复 大图APP: 明白了。。我的场景不一样,你是要获得剪切板的内容,而我是要复制东西。。这个在appjs里面实现不了

    2021-06-03 13:13

该问题目前已经被锁定, 无法添加新回复