Q: How to change language PDF page indicator? - swift

I want to change the language of the page indicator, it should be german and not english. If you scroll inside of a pdf file it shows you "1 of 6" that's what i want to change.
Any ideas?
import UIKit
import WebKit
class PDFViewController: UIViewController {
var pdfName: String?
#IBOutlet weak var wkWebView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
let pdfFilePath = Bundle.main.url(forResource: pdfName!, withExtension: "")
let urlRequest = URLRequest.init(url: pdfFilePath!)
wkWebView.load(urlRequest)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}

Xcode Project -> Info -> Localizations add German
was the answer!
Thanks #Retterdesdialogs

Related

Can't see anything in Web.load(URLRequest(url: URL(string: "https://google.com")!))

I am trying to make a macOS app using Xcode 12.4 , that opens webpages. When I try to use Web.load(URLRequest(url: URL(string: "https://google.com")!)) , I see an empty window.
I use a WKWebView in Main.storyboard
Here is the ViewController.swift code:
import Cocoa
import WebKit
let webView = WKWebView()
class ViewController: NSViewController {
#IBOutlet weak var Search: NSSearchField!
#IBOutlet weak var Web: WKWebView!
var web: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
Web.load(URLRequest(url: URL(string: "https://google.com")!))
// Do any additional setup after loading the view.
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
}
I just found the simplest solution to this problem: remove the App Sandbox! More information about this here: https://developer.apple.com/forums/thread/92265

URL validation not working in swift

started learning swift two weeks ago, with no previous programming experience, and I can't for the life of me figure out why this wouldn't work to check for nil. it just crashes when trying to load a web page if the user enters an invalid URL. This is the ENTIRETY of the code.
import UIKit; import WebKit
class ViewController: UIViewController {
#IBOutlet weak var adressBar: UITextField!
#IBOutlet weak var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
#IBAction func returnPressed(_ sender: Any) {
if let adressBarText = adressBar.text {
if let myURL = URL(string: adressBarText) {
let myRequest = URLRequest(url: myURL)
webView.load(myRequest)
adressBar.resignFirstResponder()
print("EYYYYY")
} else {
print("BOOOO")
}
}
}
}
Try this method
func verifyUrl (urlString: String?) -> Bool {
//Check for nil
if let urlString = urlString {
// create NSURL instance
if let url = NSURL(string: urlString) {
// check if your application can open the NSURL instance
return UIApplication.sharedApplication().canOpenURL(url)
}
}
return false
}
https://stackoverflow.com/a/30130535/8069241

Mac OSX app not loading URL in Webkit View

I am trying to load a URL inside a Webkit View in a Mac OX app using Swift.
This is how my code looks like right now:
import Cocoa
import AppKit
import Foundation
import CoreData
import WebKit
class ViewController: NSViewController, WKUIDelegate {
#IBOutlet weak var rightBox: NSView!
#IBOutlet weak var leftBox: NSView!
#IBOutlet var myWebView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
self.view.wantsLayer = true
// Do any additional setup after loading the view.
}
override func viewWillAppear() {
leftBox.layer?.backgroundColor = NSColor.blue.cgColor
rightBox.layer?.backgroundColor = NSColor.red.cgColor
let myURL = URL(string: "https://www.apple.com")
let myRequest = URLRequest(url: myURL!)
myWebView.load(myRequest)
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
}
When I run the code, I only see blank white box.
I have tried placing the url loading code both in the viewDidLoad as well as viewWillAppear. Same result.
I am trying to figure out what I might be doing wrong.
Any suggestions?
Thanks
Have you enabled outgoing connections for your application?
Had it been an http:// URL you'd also have to turn on NSAllowsArbitraryLoads in your Info.plist.

Swift UIWebView remove Edge

As you can see in the Picture below there are edges.
When I embed the View with a NavigationView, than the edges appears. So how can I avoid this edges??
Thanks
import UIKit
class ShowSubmitViewController: UIViewController, UIWebViewDelegate {
#IBOutlet weak var webView: UIWebView!
var URL : String = ""
var type : Int = 0
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
loadBrowser()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func loadBrowser(){
switch type {
case 5:
let htmlString:String! = URL
webView.loadHTMLString(htmlString, baseURL: nil)
default:
let url = NSURL (string: URL);
let requestObj = NSURLRequest(URL: url!);
webView.loadRequest(requestObj);
}
}
}
Picture WebView with Edge

Swift use of unresolved identifier 'webView'

I want to add a webview to my application, but i keep getting this freaking error for webview. Please help!
import UIKit
class Browse: UIViewController {
#IBOutlet weak var browseweb: UIWebView!
let browseurl = "http://google.com"
override func viewDidLoad() {
super.viewDidLoad()
let requestURL = NSURL(string:browseurl)
let request = NSURLRequest(URL: requestURL!)
webView.loadRequest(request)
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Your variable is called browseweb, but you call webView.loadRequest(request). You need to use the same name...