قالب وردپرس درنا توس
Home / IOS Development / I come by myself … over iOS pdfKit (swift)

I come by myself … over iOS pdfKit (swift)




So, background, this is a cry for help and a rant.

… I'm new to fast, pretty familiar with Obj / c.

Having played with xcode the last few days I get it. But this pdfkit kills me. The functionality that apple says is just not! I've read docs, but they're all written in Obj / c.

I've been trying to create a simple pdf document search function over the last 8 hours.

import UIKit

import PDFKit

class TryoutViewController: UIViewController, PDFDocumentDelegate, UISearchBarDelegate { [19659005]

]

super.viewDidLoad ()

self.title =)

override func viewDidLoad () { file name la searchBar = UISearchBar ()

searchBar.searchBarStyle = UISearchBarStyle.prominent

searchBar.placeholder = "Search ..."

searchBar.sizeToFit ()

searchBar.isTranslucent = false

searchBar.barTintColor . 1

9659002] searchBar.trailingAnchor.constraint (likeTo: view.safeAreaLayoutGuide.trailingAnchor) .isActive = true

searchBar.topAnchor.constraint (likeTo: view.safeAreaLayoutGuide.topAnchor) .isActive = true . : farezon

// - end DZ

la pdfView = PDFView ()

pdfView.translatesAutoresizingMaskIntoConstraints = false

] view.addSubview (pdfView) [19659002] searchBar.bottomAnchor.constraint (likeTo: pdfView.topAnchor) .isAct ive = true pdfView.heightAnchor.constraint (equalToConstant: 104) .isActive = true

] pdfView.backgroundColor = UIColor.groupTableViewBackground

] pdfView.leadingAnchor.constraint (likeTo: view.safeAreaLayoutGuide.leadingAnchor) .isActive = true

] pdfView.trailingAnchor.constraint (likeTo: view.safeAreaLayoutGuide.trailingAnchor) .isActive = true [19659002] pdfView.topAnchor.constraint (likeTo: searchBar.bottomAnchor) .isActive = true

la thumbnailView = PDFThumbnailView ()

thumbnailView.translatesAutoresizingMaskIntoConstraints = false

view.addSubview (thumbnailView)

pdfView.bottomAnchor.constraint (likeTo: thumbnailView .topAnchor) .isActive = tr e

thumbnailView .backgroundColor = UIColor.clear

tue mbnailView.tintColor = UIColor.clear

thumbnailView.leadingAnchor.constraint (like : view.safeAreaLayoutGuide.leadingAnchor) .isActive = true

thumbnailView.trailingAnchor.constraint (equalTo: view.safeAreaLayoutGuide.trailingAnchor) .isActive = true

thumbnailView.bottomAnchor .constraint (likeTo: view.safeAreaLayoutGuide.bottomAnchor) .isActive = true thumbnailView.heightAnchor .constraint (equalToConstant: 52) .isActive = true

thumbnailView.thumbnailSize = CGSize (width: 30, height: 50)

thumbnailView.layoutMode =

thumbnailView.pdfView = pdfView

guard let path = Bundle.main.path (forResource: filename, ofType: "pdf") an net {return} [19659002] if pdfDocument = PDFDocument (URL: URL (fileURLWithPath: path)) {

pdfView.displayMode = .singlePageContinuous

pdfView.autoScales = true

] // view loaded

} // end

I know that I have to implement the search function outside ViewDidLoad, but where do I go from there? Some?

sent by / u / BoomSheekah
[comments]
Source link