小编joh*_*Doe的帖子

PDFKit - PDFThumbnailView 跳过页面而不是显示连续页面 - swift

我能够呈现我的 pdf 文档的 PDFThumnailView。问题是它正在跳页。它显示第 1、3、5 页等...而不显示中间的页面。我的代码如下。

@IBOutlet weak var pdfView: PDFView!
@IBOutlet weak var pdfThumbnailView: PDFThumbnailView!

 func setupThumbnailView() {
    pdfThumbnailView.pdfView = pdfView
    pdfThumbnailView.thumbnailSize = CGSize.init(width: thumbnailDimension, height: thumbnailDimension)
    pdfThumbnailView.backgroundColor = sidebarBackgroundColor

}
Run Code Online (Sandbox Code Playgroud)

pdfkit pdfview ios swift

5
推荐指数
1
解决办法
1536
查看次数

如何快速将 UIImage 中的 PDF 放入 PDFView 中?

我有一个应用程序可以捕获图像并将其转换为 pdf。然后将其显示在 PDFView 中。但是,PDF 不适合我的 PDFView 的尺寸。如何缩放 pdf 以适合 PDFView?

当从 imagePickerController 中选择图像时,将执行以下函数:

// OUTLETS
@IBOutlet weak var myPDFView: PDFView!


 func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

    print("image selected ...")
    // Get picked image info dictionary
    let image = info[UIImagePickerControllerOriginalImage] as! UIImage

    // Add captured and selected image to your Photo Library
    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)

    // Create PDFDocument object and display in PDFView
    let document = createPDFDataFromImage(image: image)

    myPDFView.document = document
    myPDFView.scaleFactorForSizeToFit

    // Dimiss imagePicker
    dismiss(animated: …
Run Code Online (Sandbox Code Playgroud)

pdfkit pdfview ios swift

4
推荐指数
1
解决办法
3520
查看次数

在搜索栏外单击时使键盘消失 - SWIFT

我有一个 UIViewController 并且我嵌入了一个搜索栏和一个集合视图。当我按下搜索栏时,键盘出现。如果用户决定通过点击屏幕上除搜索栏以外的任何位置来改变主意,我想隐藏此键盘。我尝试了以下但没有成功:

  1. 添加点击手势识别器
  2. 使用 'self.mySearchBar.endEditing(true)'

    class CollectionViewFolder: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate ,UICollectionViewDelegateFlowLayout, UISearchBarDelegate{
    
    /*** OUTLETS ***/
    @IBOutlet weak var mySearchBar: UISearchBar!
    
    
    // 1. I have tried adding a Tap Gesture Recognizer
    // TAP ON SCREEN LISTENER
    @IBAction func tapOnScreen(_ sender: UITapGestureRecognizer) {
       print("tap tap ...")
       self.mySearchBar.resignFirstResponder()
    }
    
    
    
    // 2.  Added the following to the viewDidLoad:
    override func viewDidLoad() {
       super.viewDidLoad()
    
       self.mySearchBar.endEditing(true)
     }
    
    }
    
    Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

ios searchbar swift

2
推荐指数
1
解决办法
1222
查看次数

使用 Hardhat 在 EtherScan 上验证智能合约时出错

以下是我的智能合约(已部署)。当我尝试验证它以将代码提交到 Etherscan 时,我收到以下错误,我真的不知道为什么。请问有人可以建议吗?

 npx hardhat verify --network ropsten 0xE9abA803d6a801fce021d0074ae71256C9F24Da4
Run Code Online (Sandbox Code Playgroud)

错误信息:

 Error in plugin @nomiclabs/hardhat-etherscan: More than one contract was found to match the deployed bytecode.
 Please use the contract parameter with one of the following contracts:
 * @openzeppelin/contracts/finance/PaymentSplitter.sol:PaymentSplitter
  * contracts/MyNFTContract.sol: MyNFTContract

 For example:

   hardhat verify --contract contracts/Example.sol:ExampleContract <other args>

 If you are running the verify subtask from within Hardhat instead:

   await run("verify:verify", {
     <other args>,
     contract: "contracts/Example.sol:ExampleContract"
  };
Run Code Online (Sandbox Code Playgroud)

MyNFTContract.sol:

 // SPDX-License-Identifier: MIT
 pragma solidity ^0.8.0;

 import "@openzeppelin/contracts/finance/PaymentSplitter.sol";

 contract MyNFTContract is …
Run Code Online (Sandbox Code Playgroud)

solidity smartcontracts openzeppelin hardhat

2
推荐指数
1
解决办法
7055
查看次数

如何使用 javascript(无 jQuery)动画滚动到页面顶部?

我想在按下网页按钮时执行转换以慢慢滚动回页面顶部。我知道如何使用类中的更改来执行转换,但在这种情况下,我该怎么做?

document.documentElement.scrollTop = 0;
Run Code Online (Sandbox Code Playgroud)

javascript css transition

1
推荐指数
1
解决办法
3548
查看次数

为以太坊交易分配“值”参数

我正在尝试将 0.05 以太币的值分配给以太坊交易的 value 参数,如下面的代码所述。我不明白如何将 50000000000000000 Wei (0.05 Eth) 转换为描述的格式“0x29a2241af62c0000”。请有人告诉我如何将 50000000000000000 wei 转换为这种格式,它到底是什么?

//Sending Ethereum to an address
sendEthButton.addEventListener('click', () => {
  ethereum
    .request({
      method: 'eth_sendTransaction',
      params: [
        {
          from: accounts[0],
          to: '0x2f318C334780961FB129D2a6c30D0763d9a5C970',
          value: '0x29a2241af62c0000',
          gasPrice: '0x09184e72a000',
          gas: '0x2710',
        },
      ],
    })
    .then((txHash) => console.log(txHash))
    .catch((error) => console.error);
});
Run Code Online (Sandbox Code Playgroud)

solidity smartcontracts metamask

1
推荐指数
1
解决办法
1842
查看次数

如何从导航堆栈中删除ViewController,而不能选择返回它 - Swift

我有一个登录页面,如果登录成功,用户将被带到登陆viewController(VC).我有一个navigationController.我弹出登录VC并推入登陆VC.我遇到的问题是登录VC在堆栈中持续存在,如导航控制器上的左键所示,它会导航回登录页面.如何从堆栈中完全删除登录VC,以便导航控制器在用户登录后无法导航回用户?

 self.navigationController?.popViewController(animated: true)

 let landingPage = self.storyboard?.instantiateViewController(withIdentifier: "landingPage") as! 
 LandingViewController

 self.navigationController?.pushViewController(landingPage, animated: true)
Run Code Online (Sandbox Code Playgroud)

uinavigationcontroller ios swift

0
推荐指数
1
解决办法
1239
查看次数