iOS object-c 添加ignore文件内容

本文档提供了关于Xcode的构建设置与gitignore文件的配置建议,包括如何正确地忽略Xcode生成的临时文件,确保项目的干净整洁,并且介绍了Objective-C与Swift项目中常用的gitignore条目。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspective...

转载于:https://my.oschina.net/zhuzhu1223/blog/628464

PDF生成错误:, TypeError: undefined is not a function (near '...webview.contentsToPDF...') at pages/home/components/webview.vue:76 __ERROR <template> <view class="webview-container"> <cover-view class="webview-wrapper"> <web-view :src="webviewPath" id="targetWebview" ></web-view> </cover-view> <cover-view class="bottom-action-area"> <cover-view class="capture-btn" @click="generatePdfFromWebview"> <cover-view class="btn-text">立即取证</cover-view> </cover-view> </cover-view> </view> </template> <script setup lang="ts"> import { onLoad } from '@dcloudio/uni-app'; import { ref } from 'vue'; const currentPageInfo = ref(''); const webviewPath = ref(''); onLoad((options: any) => { if (options.url) { webviewPath.value = decodeURIComponent(options.url); } }); const generatePdfFromWebview = async () => { // 获取当前webview对象 // const pages = uni.getCurrentPages(); // if (!pages.length) return; // // 获取当前页面实例(最后一个页面) // const currentPage = pages[pages.length - 1]; // // 获取当前页面的原生Webview对象 // const currentWebview = currentPage.$getAppWebview(); // // 获取Webview子组件(即web-view组件) // const webview = currentWebview.children()[0] // // 捕获网页内容并转换为PDF // webview.capture((captureResult) => { // if (captureResult) { // // 生成PDF文件路径 // const pdfPath = '_doc/' + Date.now() + '.pdf'; // plus.io.resolveLocalFileSystemURL(pdfPath, (entry) => { // entry.createWriter((writer) => { // writer.write(captureResult); // writer.onwriteend = () => { // // 跳转到PDF预览页 // uni.navigateTo({ // url: `pages/home/components/Webpreview?pdfPath=${encodeURIComponent(pdfPath)}` // }); // }; // }); // }); // } // }, { // format: 'pdf', // 指定生成PDF格式 // quality: 100, // 质量设置 // filename: 'webview-content' // 文件名 // }); try { uni.showLoading({ title: '生成中...', mask: true }); const filePath = await captureWebviewPDF(); uni.hideLoading(); uni.navigateTo({ url: `/pages/home/components/Webpreview?pdfPath=${encodeURIComponent(filePath)}` }); } catch (e) { uni.hideLoading(); uni.showToast({ title: `生成失败: ${e}`, icon: 'none', duration: 3000 }); console.error('PDF生成错误:', e); } }; const captureWebviewPDF = (): Promise<string> => { return new Promise((resolve, reject) => { // 获取当前页面WebView对象 const pages = getCurrentPages(); if (!pages.length) return reject('页面栈为空'); const currentPage = pages[pages.length - 1]; // @ts-ignore const currentWebview = currentPage.$getAppWebview?.() || currentPage.$scope?.$getAppWebview?.(); if (!currentWebview) return reject('无法获取WebView对象'); const webview = currentWebview.children()[0]; const platform = uni.getSystemInfoSync().platform; // if (platform === 'android') { // // Android 解决方案 // plus.android.importClass('android.graphics.Bitmap'); // plus.android.importClass('android.graphics.pdf.PdfDocument'); // webview.captureBitmap((bitmap: any) => { // try { // const pdfDoc = new plus.android.newObject('android.graphics.pdf.PdfDocument'); // const pageInfo = new plus.android.newObject( // 'android.graphics.pdf.PdfDocument$PageInfo$Builder', // bitmap.getWidth(), // bitmap.getHeight(), // 1 // ).create(); // const page = pdfDoc.startPage(pageInfo); // page.getCanvas().drawBitmap(bitmap, 0, 0, null); // pdfDoc.finishPage(page); // const fileName = `capture_${Date.now()}.pdf`; // const filePath = `${plus.io.PUBLIC_DOWNLOADS}/${fileName}`; // const stream = plus.io.createStream(filePath); // pdfDoc.writeTo(stream); // stream.close(); // resolve(filePath); // } catch (e) { // reject(`Android生成失败: ${e}`); // } // }); // } else if (platform === 'ios') { // iOS 解决方案 const fileName = `capture_${Date.now()}.pdf`; const filePath = `${plus.io.PUBLIC_DOCUMENTS}/${fileName}`; webview.contentsToPDF({ filename: filePath }, (res: any) => { resolve(filePath); }, (err: any) => { reject(`iOS生成失败: ${err}`); }); // } else { // reject('不支持该平台'); // } }); }; </script> <style> .webview-container { position: relative; width: 100%; height: 100vh; overflow: hidden; } .webview-wrapper { height: calc(100vh - 120rpx); width: 100%; overflow: hidden; } .bottom-action-area { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; background-color: #007aff; padding: 30rpx; padding-bottom: constant(safe-area-inset-bottom); padding-bottom: env(safe-area-inset-bottom); display: flex; justify-content: center; align-items: center; } .capture-btn { width: 100%; height: 90rpx; background-color: #007aff; border-radius: 45rpx; box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.2); display: flex; align-items: center; justify-content: center; } .btn-text { color: #ffffff; font-size: 32rpx; font-weight: 500; } /* PDF预览组件样式 */ .custom-preview { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 9999; background-color: rgba(0, 0, 0, 0.9); display: flex; flex-direction: column; align-items: center; padding: 0 0 40rpx 0; box-sizing: border-box; } .preview-header { width: 100%; height: 100rpx; background-color: #007aff; color: #ffffff; display: flex; align-items: center; justify-content: center; position: relative; } .title-container { display: flex; align-items: center; justify-content: center; width: 100%; } .preview-title { color: #ffffff; font-size: 34rpx; font-weight: bold; } .close-btn { position: absolute; right: 30rpx; font-size: 40rpx; color: white; } .preview-pdf { width: 100%; height: calc(100% - 100rpx - 120rpx); background-color: white; } .action-buttons { display: flex; width: 100%; justify-content: space-between; padding: 30rpx 5%; margin-top: auto; background-color: #353336; box-sizing: border-box; } .action-btn { flex: 1; height: 90rpx; border-radius: 12rpx; display: flex; align-items: center; justify-content: center; margin: 0 15rpx; color: #ffffff; font-size: 34rpx; font-weight: 500; } .cancel-btn { background-color: #666; } .confirm-btn { background-color: #007aff; } </style>
最新发布
08-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值