3***@qq.com
3***@qq.com
  • 发布:2024-10-23 16:46
  • 更新:2024-10-28 13:11
  • 阅读:220

【报Bug】使用 uni.getLocation 包错

分类:uni小程序sdk

产品分类: uni小程序SDK

手机系统: iOS

手机系统版本号: iOS 18

手机厂商: 苹果

手机机型: iphone xr

页面类型: vue

SDK版本号: 最新

操作步骤:

这个是uniapp代码

<template>
<view class="container">
<cover-text class="address">test</cover-text>
<cover-text class="address">{{ func }}</cover-text>
<cover-text class="address">{{ address }}</cover-text>
<camera
id="myCamera"
mode="normal"
binderror="onCameraError"

</camera>

<canvas  
  class="canvas"  
  canvas-id="myCanvas"  
  style="width: 300px; height: 300px"  
></canvas>  
<cover-view class="bottomArea">  
  <view class="circle" @click="takePhoto">  
    <view class="inCircle"></view>  
  </view>  
</cover-view>  

</view>
</template>

<script setup>

import { ref } from "vue";
import { onLoad } from "@dcloudio/uni-app"

const photo = ref(null);
const address = ref(null);
const func = ref(null);

const onCameraError = (error) => {
console.log('==errorerror==================================');
console.log(error);
console.log('====================================');
}

const takePhoto = () => {
const cameraContext = uni.createCameraContext(this);
cameraContext.takePhoto({
quality: "high",
success: (res) => {
photo.value = res.tempImagePath; // 更新照片
console.log('====================================');
console.log(photo.value);
console.log('====================================');
},
fail: (error) => {
address.value = error;
console.error("Take photo failed:", error);
}
});
};

onLoad(() => {
func.value = uni.getLocation;
uni.getLocation && uni.getLocation({
// altitude: true,
// geocode: true,
success: (res) => {
console.log('=resres===================================');
console.log(res);
console.log('====================================');
address.value = res;
},
fail: (error) => {
address.value = error;
console.log('==errorerror==================================');
console.log(error);
console.log('====================================');
}
})
})

</script>

<style lang="scss" scoped>
.container {
position: relative;
height: 100vh; / 确保占满整个屏幕 /
.address{
// position: fixed;
width: 100vh;
left: 0;
top: 0;
z-index: 100;
color: red;
height: 500rpx;
word-break:break-all;
word-wrap: break-word;
}
.canvas {
position: fixed;
z-index: 1;
}
.bottomArea {
position: fixed;
bottom: 0;
left: 0;
width: 100vw;
height: 180rpx;
display: flex;
align-items: center;
justify-content: center;
z-index: 12;
background: #000;
.circle {
width: 120rpx;
height: 120rpx;
background: transparent;
border: 2rpx solid #fff;
box-sizing: border-box;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
.inCircle {
box-sizing: border-box;
width: 100rpx;
height: 100rpx;
background: #fff;
border-radius: 50%;
}
}
}

myCamera {

width: 100vw;  
height: calc(100vh - 80rpx);  
position: relative;  
z-index: 10;  

}
}
</style>

预期结果:

正常使用就行

实际结果:

正常使用就行

bug描述:

在ios中集成unimpsdk。

使用 uni.getLocation 时包错:This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the -locationManagerDidChangeAuthorization: callback and checking authorizationStatus first.

uni.getLocation && uni.getLocation({
// altitude: true,
// geocode: true,
success: (res) => {
console.log('=resres===================================');
console.log(res);
console.log('====================================');
address.value = res;
},
fail: (error) => {
address.value = error;
console.log('==errorerror==================================');
console.log(error);
console.log('====================================');
}
})

iOS配置了:

pod 'unimp', :subspecs => [
'Core', ## 核心库(必需)
'File', ## 文件
'Camera&Gallery', ## 相机&相册
'Geolocation-Gaode', ##高德定位
]

权限也加了,见附件

再就是 使用 <camera></camera> 在ios上也有问题

2024-10-23 16:46 负责人:无 分享
已邀请:
DCloud_iOS_XHY

DCloud_iOS_XHY

下载SDK包,使用包里面的demo工程手动将依赖库添加进去测试一下是否正常,如果正常就是pod添加库失败了,Cocoapods 集成的话,需要 git lfs ,检查一下是否配置成功,然后重新执行一下 pod install

要回复问题请先登录注册