使用SwiftUI和PDFKit来实现翻页功能

swift 专栏收录该内容
¥59.90 ¥99.00
66篇文章

在SwiftUI中使用PDFKit来展示PDF文件并实现翻页功能是一项常见的任务。本文将详细介绍如何在SwiftUI中使用PDFKit来响应翻页消息,并提供相应的源代码示例。

首先,确保你的项目中已经导入了PDFKit框架。你可以在Xcode的工程设置中添加PDFKit.framework,或者使用CocoaPods或Carthage等依赖管理工具来添加。

接下来,我们创建一个名为PDFViewWrapper的自定义视图,用于封装PDFKit的PDFView。这个封装器将处理翻页消息的响应。

import SwiftUI
import PDFKit

struct PDFViewWrapper: UIViewRepresentable {
   
   
    
iOS开发教程之在 Swift 中使用 PDFKit 动态生成 PDF(教程含源码) 在开发 Swift 应用程序时,动态生成 PDF 报告非常有用。您的用户将能够在旅途中创建他们自己的个性化报告,他们将能够非常轻松地导出这些报告。 阅读详情

相关推荐

SwiftUI PDFKit如何响应翻页消息

实战需求 SwiftUI PDFKit如何响应翻页消息? 实战代码 class ViewController: NSViewController { @IBOutlet weak var pdfView: PDFView! @IBOutlet weak var textView: NSTextView! override func viewDidLoad() { super.viewDidLoad() self.pdfView.accept

iCloudEnd的博客 666

SwiftUI 开发经验之我希望我作为一个新人了解从头开始构建 iOS 应用程序

我作为新人的经历并不是在红地毯上散步,这是不同的,我被安排做修补程序、集成、转换项目等等,而不是从头开始新项目。现在回想起来,人们对我的信任让我不知所措,我很感激作为一名新生获得的机会。所以我决定提供帮助,或者给新生或任何努力从头开始构建应用程序的人一些信心。由于这个博客是专门为 iOS 写的,所以我将切断 iOS 端,如果你想要其他技术堆栈,请随时发表评论,并肯定会制作一个博客。...

iCloudEnd的博客 665

SwiftUI 高级列表分页与无限滚动的实现

通过结合 List 和 ScrollView,以及使用分页加载和滚动监听的技术,我们可以轻松实现这些功能。在本文中,我们将探讨如何在 SwiftUI 中实现高级列表分页与无限滚动的功能。我们将使用 SwiftUI 的 List 和 ScrollView 来展示数据,并结合分页加载和滚动监听的技术来实现无限滚动效果。当用户滚动到列表的底部时,将自动加载下一页数据,并在列表末尾展示新的项目。接下来,我们将创建一个 SwiftUI 视图来展示项目列表,并实现分页加载和无限滚动的功能。的实例,以便在视图中使用它。

BUG?不存在的! 698

SwiftUI实战:包含epub、pdf及源码下载

SwiftUI是由苹果公司推出的一套全新的用户界面框架,用于开发iOS、macOS、watchOS和tvOS应用程序。与UIKit和AppKit不同,SwiftUI让开发者可以用Swift语言的声明式语法来创建用户界面。2019年WWDC(苹果全球开发者大会)上,SwiftUI首次亮相,成为当时iOS开发界的热门话题。 SwiftUI的核心理念是声明式编程,这种方式让开发者定义视图应该如何响应数据变化。开发者只需要描述用户界面看起来是什么样子的,而不需要具体操作视图的加载和卸载过程。这不仅简化了代码,而且提高了效率和性能。SwiftUI还兼容Swift的所有新特性,比如SwiftUI中的@State、@Binding等属性包装器能够实现数据驱动视图更新。 在学习SwiftUI时,一本书或者一个教程可以为你提供系统的知识框架。《SwiftUI by Tutorials》这本书就是一个学习SwiftUI的实用指南。本书以教程的形式,一步步地引导开发者从基础到深入的掌握SwiftUI。本书不仅涵盖理论知识,更着重于实践操作,每一章节都有配套的示例代码,让读者可以在实践中学习。 此书的内容通常会包含以下几个方面: 1. **SwiftUI基础**:介绍SwiftUI的基本组件和布局方法,包括如何使用View、Text、Button等基本UI元素,以及Stacks、Modifiers等布局技术。 2. **数据状态管理**:讲解如何在SwiftUI中管理数据状态。SwiftUI使用了一种新的状态管理方法,开发者需要了解如何使用@State、@Binding、@Environment等属性包装器来实现状态的传递和管理。 3. **动画与交互动画**:SwiftUI提供了丰富的API来实现动画效果。这部分内容会教读者如何为视图添加交互动画以及如何控制动画的细节。 4. **

iOS 必学:SwiftUI 与 Combine编程(最新版)

iOS 必学:SwiftUI 与 Combine编程(最新版)

SwiftUI.Essentials.iOS.15和16.Edition PDF

对于学习SwiftUI的同学, 熟悉IOS15以及16 资源很是有用

512分辨率万能遮罩模型实战指南:从下载到高精度应用

本文提供了512分辨率万能遮罩模型的完整实战指南。该模型经过超过540万次迭代,专门优化了对头发、手、眼睛等复杂区域的识别。文章详细介绍了从可靠渠道下载、环境部署、使用DF_ICE工具批量应用遮罩,到利用XSeg Editor进行高精度精修的全流程,旨在帮助用户显著提升AI换脸合成视频的质量与效率。

y2z3a4b5c的博客 1165

Intel网卡固件烧录实战:eeupdate与bootutil命令完全解析

固件作为硬件设备底层运行的软件,其稳定性直接决定硬件功能的完整性。网卡固件一旦损坏,常表现为MAC地址丢失、PXE启动失效、NVM数据异常导致降速或掉线。维护这类问题,需借助Intel官方工具eeupdate与bootutil在UEFI Shell或DOS环境下执行底层烧录操作。eeupdate负责网卡的身份信息与NVM存储管理,可重置MAC、恢复固件镜像;bootutil则专管启动行为,支持PXE配置与Boot Agent升级。从环境准备、命令参数到故障恢复,掌握这两款工具能让运维人员在修复存量网卡、应对

weixin_34269583的博客 312

从零搭建Obsidian智能知识库:Ollama本地模型与Copilot插件实战指南

本文详细介绍了如何从零搭建Obsidian智能知识库,结合Ollama本地模型与Copilot插件实现高效知识管理。通过本地部署AI助手,用户可以在保证隐私安全的同时,快速检索和整理笔记,提升工作效率。文章涵盖硬件准备、Ollama部署、插件配置及实战技巧,适合需要高效知识管理的专业人士。

weixin_29230773的博客 631

IP-Guard安全网关实例

企业相关情况: 1.OA系统,主要为日常工作使用,该系统IP为192.168.1.2,端口为8080; 2.文件共享服务器,用于存放日常工作资料和文档,该文件共享服务器的IP为192.168.1.1,其中\\192.168.1.1\private 目录中的存放着公司重要文档,不能随意外传; 3.安全网关已采用串联的方式联入网络,IP为192.168.2.6,所有机器访问OA系统和文件共享服务...

IP-Guard专栏 707

【打卡帖】7日玩转ESP32——(第4日) 串口的输入输出

【福利帖】7日玩转ESP32——(第4日) 串口的输入输出

1377

ethernet eth0: Could not attach to PHY

整个流程看下来就是MAC connect PHY的过程失败了,失败的具体原因根据config_init,上图(bcm54xx_config_init) ,从此方向入手去定位原因;我这里的问题是has_gmac4没有置1,根据 has_gmac4: uses GMAC4 core.按照上面的调用逻辑,添加了部分打印,定位到__phy_read接口返回失败。stmmac_mdio_read 大部分都是linux的标准接口。最终取决于平台用的是哪家的phy,调用config_init。

无线互联&网络介绍 2702

Kong API Gateway 配置与深入

Kong是一个开源的、高性能的API网关,提供了一种简单易用的服务间路由、流量管理和安全防护方案,其最初起源于Nginx Inc.,但后迁移至Apache Software Foundation。Kong支持RESTful、GraphQL、TCP/UDP等协议,可与AWS Lambda、Azure Functions、Google Cloud Functions等云函数平台集成。其主要功能包括:服务发现与负载均衡、请求代理、身份认证与授权、缓存、日志记录、监控指标、灰度发布、多种插件等。

AI天才研究院 2283

【CANdelaStudio编辑CDD】-2.2-给$27服务SecurityAccess创建一个SecurityLevel安全级别并修改SecurityAccess安全访问状态机(UDS诊断)

前一篇: 【UDS诊断描述文件CDD】-2.1-ISO_14229中$27服务理论部分https://blog.youkuaiyun.com/qfmzhu/article/details/120392660 案例背景: 在CDD中如何给$27服务创建一个新的SecurityLevel安全级别; 在CDD中如何给$27服务修改SecurityAccess安全访问状态机。 1 查看$27服务中已有的SecurityLevel安全级别 2 查看$27服务中已有的SecurityAccess安全...

「汽车电子助手」的博客 4642

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: SwiftUI中使用List和NavigationLink组合可以创建一个具有导航功能的列表视图
下一篇: SwiftUI 键盘组件详解与更新
普通网友
博客等级 码龄3年 22粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值