Posts

Post marked as solved
5 Replies
14k Views
I am working on the ios project. I didn't have any problem at the moment. However, there is a problem with iOS 11.4 version of iPhone 6.I've already built my project with the iOS 12.4 iPhone 6 device, and there's nothing wrong with it.This is a problem when you connect a physical device. My error is as follows. Undefined symbols for architecture arm64: "_UTTypeConformsTo", referenced from: myapp.Document.uti(_: Swift.String, conformsTo: Swift.String) -> Swift.Bool in Document.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Undefined symbol : _UTTypeConformsToI have this function in the `Document.swift` file.**Document.swift**~~~swiftclass Document: UIDocument { var fileData: Data? var filesText: Data? func uti(_ uti: String, conformsTo candidateParent: String) -> Bool { return UTTypeConformsTo(uti as CFString, candidateParent as CFString) } ... override func load(fromContents contents: Any, ofType typeName: String?) throws { if let fileType = typeName { if fileType == "public.png" || fileType == "public.jpeg" { // .jpg not recognized if let fileContents = contents as? Data { fileData = fileContents } } else if !uti(typeName!, conformsTo: "public.data") { throw IXError.fileAcessFailed } else { if let fileContents = contents as? Data { filesText = fileContents } print("File type unsupported.") } } // end if let fileType = typeName } // end func load~~~problematic environment:- Xcode: Version 11.0- Device : IPhone 6 and 11.4 ios version // get Error- Device : IPhone 6 and 12.4 ios version // This device operates normally.The two devices are different.There have been no problems so far, but problems occur when trying to build this device. What's the problem?##EDIT ###The error appears to occur when the developer info is set to 11.4. However, 11.4 devices must also be able to be built. What is the fundamental solution?
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.8k Views
I click the button to go to another Webview. However, I removed the bounce from the moved Webview, but it does not work.First WKWebView var openSecondScreen : SecondWebViewController! var preloadCheck = false ... func openSecondScreen(){ let storyboard = UIStoryboard(name: "Main", bundle: nil) openSecondScreen = storyboard.instantiateViewController(withIdentifier: "SecondWebViewController") as! SecondWebViewController openSecondScreen.delegate = self openSecondScreen.loadViewIfNeeded() openSecondScreen.secondWKWebView.navigationDelegate = self preloadCheck = true }.... func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { if preloadCheck { self.navigationController?.pushViewController(openSecondScreen, animated: true) preloadCheck = false } }Second WKWebView@IBOutlet var secondWKWebView: WKWebView!...override func loadView() { super.loadView() secondWKWebView.uiDelegate = self secondWKWebView.navigationDelegate = self secondWKWebView.scrollView.delegate = self ... }extension SecondWebViewController: UIScrollViewDelegate{ func scrollViewDidScroll(_ scrollView: UIScrollView) { print("scrollViewDidScroll") scrollView.bounces = false } }Scroll does not display the log. Therefore, the function does not work either.I'm even setting it up in advance.But it didn't work override func viewDidLoad() { super.viewDidLoad() secondWKWebView.scrollView.bounces = false }
Posted Last updated
.
Post not yet marked as solved
0 Replies
228 Views
In-app payment is not available at this time, we are looking for a replacement payment because we received a message from the Apple team.So I want to proceed with the account transfer through PG company.Can this be a reject reason for launching apps? The item I want to pay for is the point using the blockchain coin.
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.6k Views
I am showing the html page using WKWebView. My problem is that after copying and pasting the page in version 13.1 of iOS, I can't see the cursor in the 'input' of a single paste page. This problem seems to occur only in 13.1 cases.Problem Reproduction Parthttps://i.stack.imgur.com/mnlgw.gifThe part where I paste the page from the js file.function questionAdd(obj) { var act = $(obj).data("role"); // add var currentIdx = $("#gameCreateSection .form-wrap").length; if (act == "add") { var targetIdx = currentIdx + 1; // Number of games to be created // Copy the last question append var lastQuestion = $("#gameCreateSection .form-wrap").last(); lastQuestion .clone() .attr({ id: "question-" + targetIdx, "data-quiz": targetIdx }) .insertAfter(lastQuestion); var newQuestion = $("#question-" + targetIdx); // New generation problem // Change the ID of the form element (ID redundancy prevention) The ID of the copied element + targetIdx newQuestion.find(".form-input").each(function () { var elID = $(this).attr("id"); if (elID == undefined || elID == null || elID == "undefined") { } else { elID = elID.split("-")[0]; // Import String Region Only $(this).attr("id", elID + "-" + targetIdx); $(this) .prev("label") .attr("for", elID + "-" + targetIdx); } }); // Other IDs and TEXT processing newQuestion .find(".form-template") .attr("id", "objectiveTemplate-" + targetIdx); newQuestion .find(".ordered-item-list") .attr("id", "objectiveItemList-" + targetIdx); newQuestion.find(".example_css").attr("name", "example_" + targetIdx); newQuestion.find(".form-input").val(""); // Initialize data entered for replication issues $("#objectiveItemList-" + targetIdx) .find("li") .remove(); //clear existing viewlist $("#objectiveItemList-" + targetIdx).html( " targetIdx + "" placeholder="Please enter question" onkeyup="form_keydown(this)"> " + " targetIdx + "" placeholder="Please enter question" onkeyup="form_keydown(this)"> " ); // create slide if ( slideSection == "undefined" || slideSection == null || slideSection == undefined ) { // call up the slide if there is no history of slide generation. slideSection = $("#gameCreateSection").bxSlider({ infiniteLoop: false, controls: false, pager: false, slideMargin: 10, touchEnabled: false }); } // Go to Added Slides var moveTarget = slideSection.getSlideCount(); slideSection.goToSlide(moveTarget - 1); sliedeInx = sliedeInx + 1;The cursor of the input seems to be visible in the other version. You can also view the input cursors in version `13.3` or `12.4` and `11.4`Has anyone solved the same problem as me?
Posted Last updated
.
Post not yet marked as solved
1 Replies
447 Views
I am loading and opening another WKWebView in advance to reduce loading time for other webpages in Main WKWebView.But every time you open and close another webpage, the same page grows. When I close another webpage, I want to delete the closing webpage. What should I do?Main.js$(document).ready(function(){ var data = { apiType : "preload", parameter : encodeURI(`view/other?value="testvalue"`) } webkit.messageHandlers.TestApp.postMessage(data); ... $('#openBtn').on('click', function(){ var data = { apiType : "openOther" } webkit.messageHandlers.TestApp.postMessage(data);MainWKWebViewController.swiftfunc userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { case "preload": let parameter = message["parameter"] as! String preload(parameter) break case "openOther": openOtherScreen() break ... func preload(_ prameter: String){ let storyboard = UIStoryboard(name: "Main", bundle: nil) otherWebView = storyboard.instantiateViewController(withIdentifier: "OtherWebViewController") as? OtherWebViewController otherWebView.delegate = self otherWebView.paramFromMain = prameter otherWebView.loadViewIfNeeded() otherWebView.otherWebView.navigationDelegate = self preloadCheck = true } func openOtherScreen(){ if preloadCheck { DispatchQueue.main.async { self.navigationController?.pushViewController(self.otherWebView, animated: true) self.preloadCheck = false } } else { } } ... extension MainWKWebViewController: OtherWKWebViewControllerDelegate { func HandleData(_ key: String){ if key == "reload" { self.mainWKWebView.reload() } } }OtherWKWebViewController.swiftcase "Close": self.delegate?.HandleData("reload") self.navigationController?.popViewController(animated: true) breakSafari => Develop => TestIphone's WKwebViewListhttps://ibb.co/BctV84B
Posted Last updated
.
Post not yet marked as solved
0 Replies
553 Views
I am showing the `html` file using WKWebView. This problem occurs when you open another preloaded WKWebView from the main WKWebView, sometimes after showing a white screen. And when you see the screen, it flashes.Main.js$(document).ready(function(){ var data = { apiType : "preload", parameter : encodeURI(`view/other?value="testvalue"`) } webkit.messageHandlers.TestApp.postMessage(data); ... $('#openBtn').on('click', function(){ var data = { apiType : "openOther" } webkit.messageHandlers.TestApp.postMessage(data);MainWKWebViewController.swiftfunc userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { case "preload": let parameter = message["parameter"] as! String preload(parameter) break case "openOther": openOtherScreen() break ... func preload(_ prameter: String){ let storyboard = UIStoryboard(name: "Main", bundle: nil) otherWebView = storyboard.instantiateViewController(withIdentifier: "OtherWebViewController") as? OtherWebViewController otherWebView.delegate = self otherWebView.paramFromMain = prameter otherWebView.loadViewIfNeeded() otherWebView.otherWebView.navigationDelegate = self preloadCheck = true } func openOtherScreen(){ if preloadCheck { DispatchQueue.main.async { self.navigationController?.pushViewController(self.otherWebView, animated: true) self.preloadCheck = false } } else { } }Has anyone solved the same problem as me?I tried out the layoutIfNeeded() function in addition. But it's the same. func preload(_ prameter: String){ let storyboard = UIStoryboard(name: "Main", bundle: nil) otherWebView = storyboard.instantiateViewController(withIdentifier: "OtherWebViewController") as? OtherWebViewController otherWebView.delegate = self otherWebView.paramFromMain = prameter otherWebView.view.layoutIfNeeded() DispatchQueue.main.async { self.otherWebView.loadViewIfNeeded() self.otherWebView.otherWebView.navigationDelegate = self self.preloadCheck = true } }How can I solve this problem?
Posted Last updated
.
Post marked as solved
1 Replies
1.4k Views
I use the refresh function in WKWebview. The function is normal when performing a refresh. But when I load another html file and come back, it is not refreshed.@IBOutlet var myWebView: WKWebView! var refController:UIRefreshControl = UIRefreshControl() override func viewDidLoad() { super.viewDidLoad() refController.bounds = CGRect.init(x: 0.0, y: 50.0, width: refController.bounds.size.width, height: refController.bounds.size.height) refController.addTarget(self, action: #selector(self.webviewRefresh(refresh:)), for: .valueChanged) myWebView.scrollView.addSubview(refController) ... myWebView.uiDelegate = self myWebView.navigationDelegate = self myWebView.scrollView.delegate = self } @objc func webviewRefresh(refresh:UIRefreshControl){ refController.endRefreshing() myWebView.reload() } extension mainWebViewController: UIScrollViewDelegate{ func scrollViewDidScroll(_ scrollView: UIScrollView) { print("come in ??") if currentHtmlFileName == "Main.html" { scrollView.bounces = (scrollView.contentOffset.y <= 0) } else { scrollView.bounces = false } } }As you can see from my code, my WKWebview is scrolling, and the function is executed. However, when the function is activated on a different screen and returned, the function is not called, nor is the refresh working.The steps for reproducing a problem are as follows:1. Load the WKwebView page and execute the refresh function.2. Scroll to the bottom screen to see if there is a bounce.3. If it works normally, go to a different screen. location.href = "./other.html";4. Scroll from another screen to the bottom screen to see if there is a bounce.5. If there is no bounce normally, please return to the screen. history.back()6. And run the refresh function again.In my case, I have a bounce, but the refresh does not run, and the function is not called.Has anyone solved the same problem as me? Is this a bug?
Posted Last updated
.
Post not yet marked as solved
0 Replies
1.5k Views
I enter the source code I created by floating the html file in chrome. It works very well.But when you run this on the actual iPhone WKwebview, the value is recognized as invalid. I have to compare the dates. How can we solve this problem?js code var today = new Date(); var s_date_str = $("#startDate").val() + " " + $("#startTime").val() + ":11"; var e_date_str = $("#endDate").val() + " " + $("#endTime").val() + ":11"; var s_date = new Date(s_date_str); var e_date = new Date(e_date_str); console.log(s_date_str); console.log(e_date_str); console.log(today); console.log(s_date); console.log(e_date); if (to_date >= s_date) { alert(today is fast than startDate) return; } else if (s_date >= e_date) { alert(startDate is fast than endDate) return; }console.log data2019-11-22 10:27:11 //s_date_str2019-11-23 10:27:11 //e_date_strFri Nov 22 2019 10:22:11 GMT+0900 //todayFri Nov 22 2019 10:27:11 GMT+0900 //s_dateSat Nov 23 2019 10:27:11 GMT+0900 //e_dateData found on the iPhone by changing consol.log to alert2019-11-22 10:27:11 //s_date_str2019-11-23 10:27:11 //e_date_strFri Nov 22 2019 10:22:11 GMT+0900 //todayInvalid Date //s_dateInvalid Date //e_dateI'm using swift5I tried many things. But it doesn't work.first tried // Not working in chrome.function parseDate(input) { var parts = input.split("-"); return new Date(parts[0], parts[1] - 1, parts[2]); // Note: months are 0-based } var s_date = new Date(parseDate(s_date_str));second tried // working in chrome.var s_date = new Date(Date.parse(s_date_str));Date.parse will operate normally when the html file is run on chrome but will not work on WKWebView. console.log(Date.parse(s_date_str)); alert(Date.parse(s_date_str));log and alert data1574388551000 // chromeNaN // ios WKwebVIew
Posted Last updated
.
Post not yet marked as solved
0 Replies
1.4k Views
I'm doing a QR code scan. I use UIView to change the background color of the screen to translucent color. However, I want to make the background color of the place that scans the QR code transparent. What should I do?class QRcodeScannerViewController : UIViewController, AVCaptureMetadataOutputObjectsDelegate { @IBOutlet weak var qrcodeView: UIView! @IBOutlet weak var header: UINavigationBar! @IBOutlet weak var flash: UIButton! @IBOutlet weak var qrcodeScanArea: UIImageView! var previewLayer: AVCaptureVideoPreviewLayer! override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = UIColor.black self.qrcodeView.backgroundColor = UIColor.black.withAlphaComponent(0.5) view.layer.insertSublayer(previewLayer, at: 0) view.bringSubviewToFront(flash) view.bringSubviewToFront(header) header.setBackgroundImage(UIImage(), for: UIBarMetrics.default) header.isTranslucent = true header.backgroundColor = UIColor.clear header.shadowImage = UIImage()Current My QRcode ScanViewHere's the view I want:I tried many things. But it didn't work for me. view.addSubview(qrcodeView) let shape = CGRect(x: 0, y: 0, width: 200, height: 200) let maskLayer = CAShapeLayer() maskLayer.path = UIBezierPath(roundedRect: shape, cornerRadius: 0).cgPath maskLayer.backgroundColor = UIColor.clear.cgColor maskLayer.fillRule = CAShapeLayerFillRule.evenOdd qrcodeView.layer.mask = maskLayerThe screen I tried.I was made FocusView.swiftimport Foundation fileprivate let focusSize: CGSize = CGSize(width: 200, height: 200) class FocusView: UIView { var areaBackground: UIColor? { set { maskedFocusView.backgroundColor = newValue } get { return maskedFocusView.backgroundColor } } fileprivate let maskedFocusView: MaskedFocusView = { return MaskedFocusView() }() let focusView: UIView = { let view = UIView() view.layer.borderColor = UIColor.white.cgColor view.layer.borderWidth = 2 view.layer.masksToBounds = true return view }() override func awakeFromNib() { super.awakeFromNib() commonInit() } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) commonInit() } override init(frame: CGRect) { super.init(frame: frame) commonInit() } func commonInit() { backgroundColor = UIColor.darkGray.withAlphaComponent(0.5) translatesAutoresizingMaskIntoConstraints = false maskedFocusView.layoutSubviews() addSubview(maskedFocusView) addSubview(focusView) setupFocusViewConstraints() setupMaskedFocusViewConstraints() } func setupFocusViewConstraints() { NSLayoutConstraint.activate( focusView.centerXAnchor.constraint(equalTo: centerXAnchor), focusView.centerYAnchor.constraint(equalTo: centerYAnchor) ) let regularFocusViewConstraints = [ focusView.widthAnchor.constraint(equalToConstant: focusSize.width), focusView.heightAnchor.constraint(equalToConstant: focusSize.height) ] NSLayoutConstraint.activate(regularFocusViewConstraints) } func setupMaskedFocusViewConstraints() { NSLayoutConstraint.activate( maskedFocusView.centerXAnchor.constraint(equalTo: centerXAnchor), maskedFocusView.centerYAnchor.constraint(equalTo: centerYAnchor), maskedFocusView.topAnchor.constraint(equalTo: topAnchor), maskedFocusView.bottomAnchor.constraint(equalTo: bottomAnchor), maskedFocusView.leadingAnchor.constraint(equalTo: leadingAnchor), maskedFocusView.trailingAnchor.constraint(equalTo: trailingAnchor) ) } } // MARK: - Masked focus view fileprivate class MaskedFocusView: UIView { let maskLayer: CAShapeLayer = CAShapeLayer() override func awakeFromNib() { super.awakeFromNib() commonInit() } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) commonInit() } override init(frame: CGRect) { super.init(frame: frame) commonInit() } func commonInit() { backgroundColor = UIColor.darkGray.withAlphaComponent(0.5) maskLayer.backgroundColor = UIColor.clear.cgColor layer.mask = maskLayer translatesAutoresizingMaskIntoConstraints = false } override func layoutSubviews() { super.layoutSubviews() let width = bounds.width let height = bounds.height let x = (width - focusSize.width) / 2 let y = (height - focusSize.height) / 2 let focusRect = CGRect(x: x, y: y, width: focusSize.width, height: focusSize.height) let fullRect = CGRect(origin: bounds.origin, size: bounds.size) let path = CGMutablePath() path.addPath(UIBezierPath(rect: fullRect).cgPath) path.addPath(UIBezierPath(roundedRect: focusRect, cornerRadius: 0).reversing().cgPath) maskLayer.path = path maskLayer.fillRule = .evenOdd } } // MARK: - Layout constraints extension extension NSLayoutConstraint { /// A helper function to activate layout constraints. static func activate(_ constraints: NSLayoutConstraint? ...) { for case let constraint in constraints { guard let constraint = constraint else { continue } (constraint.firstItem as? UIView)?.translatesAutoresizingMaskIntoConstraints = false constraint.isActive = true } } } extension Array where Element: NSLayoutConstraint { func activate() { forEach { if !$0.isActive { $0.isActive = true } } } func deactivate() { forEach { if $0.isActive { $0.isActive = false } } } }and Usagelet focusview = FocusView.init(frame: qrcodeView.frame) focusview.areaBackground = UIColor.black view.addSubview(focusview)The screen I tried
Posted Last updated
.
Post marked as solved
6 Replies
2.3k Views
I am communicating with JS using Webview. I transfer into parameter api the received data again. But when Swift get an array from JS, Swift don't recognize it properly.Where to Send Data from JSvar jsonData = { data, type : "fromjs" }; alert(jsonData) webkit.messageHandlers.sendFromJS.postMessage(jsonData);Data Viewed by Alerts{ "type" = "fromjs", "data" = { "num": "one", "arr_data" : [{ "title": "test1", "val" : "testval1" }, { "title": "test2" , "val" : "testval2"}] }}I check the data received by Swift.@available(iOS 8.0, *) func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { if message.name == "sendFromJS" { let getdata = message.body as! NSDictionary print(getdata)But Swift doesn't recognize the array properly.{ type = "fromjs", data = { "num": "one", "arr_data" : ({ "title": "test1", "val" : "testval1" }, { "title": "test2" , "val" : "testval2"}) }}Swift recognizes square brackets as parentheses.How can you solve this problem? I have to send the data that I received by putting it in the parameters as it is.func apiCall(_ param: NSDictionary){ let parameters: [String: AnyObject] = param["data"] as! [String : AnyObject] Alamofire.request(url, method: .post, parameters: parameters, encoding: URLEncoding.default, headers: headers)I've changed the type of data. But it's equally unrecognizable.let getdata = message.body as! [String : Any] print(getdata)//log From Swift[ type = "fromjs", data = { "num": "one", "arr_data" : ({ "title": "test1", "val" : "testval1" }, { "title": "test2" , "val" : "testval2"}) }]To create json data in jsvar data = { num: "one" }; var data_arr = []; data_arr.push({"title": "test1", "val" : "testval1"}); data_arr.push({"title": "test2" , "val" : "testval2"}); data.arr_data = data_arr; var jsonData = { data, type : "fromjs" }; alert(jsonData) webkit.messageHandlers.sendFromJS.postMessage(jsonData);
Posted Last updated
.
Post marked as solved
1 Replies
3.0k Views
I have two independent `WKWebViewController`. I load the first `WKWebView` and then another `WKWebView` when the button is pressed.So I want to load another `WKWebView` in advance. How can I do this?Each of the two ViewControllers has WKWebView.https://ibb.co/8sRHCDNFirst WKWebView func openSecondScreen(){ let storyboard = UIStoryboard(name: "Main", bundle: nil) let openSecondScreen = storyboard.instantiateViewController(withIdentifier: "SecondWebViewController") as! SecondWebViewController openSecondScreen.modalPresentationStyle = .overCurrentContext openSecondScreen.modalTransitionStyle = .crossDissolve openSecondScreen.delegate = self self.navigationController?.pushViewController(openSecondScreen, animated: true) }Second WKWebView override func loadView() { super.loadView() let images = global.getIndicatorImage() let animatedImage = UIImage.animatedImage(with: images, duration: 1.0) self.indicatorImage.image = animatedImage contentController.add(self, name: "SecondWeb") config.userContentController = contentController secondWebWebView = WKWebView(frame: secondWebWebView.frame, configuration: config) secondWebWebView.uiDelegate = self secondWebWebView.navigationDelegate = self view.addSubview(secondWebWebView) view.addSubview(indicator) if contentController.userScripts.count > 0 { contentController.removeAllUserScripts() } let localFilePath = Bundle.main.url(forResource: webUrl, withExtension: "html") let myRequest = URLRequest(url: localFilePath) secondWebWebView.load(myRequest) }How can I solve this problem?
Posted Last updated
.
Post not yet marked as solved
10 Replies
4.9k Views
I have no problem running my app.However, if you click the Share button on my app and complete the share, turn off my app and click on the shared image on another app, it will not go to the login screen. Why doesn't it recognize the background status?switch UIApplication.shared.applicationState { case .background: LoginScreen() break case .inactive: WebViewScreen() break case .active: WebViewScreen() break default: break } return trueSo if I press the Shared button and go to my app, I can go to the webview screen without fail. But I don't want to go to the webview screen when the app is off.> Table 2-3 App states State>> Description>> Not running>> The app has not been launched or was running but was terminated by the> system.>> Inactive>> The app is running in the foreground but is currently not receiving> events. (It may be executing other code though.) An app usually stays> in this state only briefly as it transitions to a different state.>> Active>> The app is running in the foreground and is receiving events. This is> the normal mode for foreground apps.>> Background>> The app is in the background and executing code. Most apps enter this> state briefly on their way to being suspended. However, an app that> requests extra execution time may remain in this state for a period of> time. In addition, an app being launched directly into the background> enters this state instead of the inactive state. For information about> how to execute code while in the background, see Background Execution.>> Suspended>> The app is in the background but is not executing code. The system> moves apps to this state automatically and does not notify them before> doing so. While suspended, an app remains in memory but does not> execute any code.>> When a low-memory condition occurs, the system may purge suspended> apps without notice to make more space for the foreground app.The 2016 Apple document had a status value of 'Notruning'. Is it gone now? Is there a substitute status value?
Posted Last updated
.
Post marked as solved
4 Replies
2k Views
I am going to scan the `QR code` in the `webView`.`QR code` scans well and data can be read,but the problem is, the camera screen won't close after scanning. I'm running a `dismiss()` function.webView Load@IBOutlet weak var indicator: UIImageView! @IBOutlet var wkWebView: WKWebView! ... let config = WKWebViewConfiguration() contentController.add(self, name: "native") config.userContentController = contentController wkWebView = WKWebView(frame: wkWebView.frame, configuration: config) wkWebView.uiDelegate = self wkWebView.navigationDelegate = self view.addSubview(wkWebView) view.addSubview(indicator) let localFilePath = Bundle.main.url(forResource: webUrl, withExtension: "html") let myRequest = URLRequest(url: localFilePath) wkWebView.load(myRequest)QRCode Scanvar captureSession: AVCaptureSession! var previewLayer: AVCaptureVideoPreviewLayer! override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if (captureSession?.isRunning == false) { captureSession.startRunning() } } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) if (captureSession?.isRunning == true) { captureSession.stopRunning() } } func qrcodeScan(){ view.backgroundColor = UIColor.black captureSession = AVCaptureSession() guard let videoCaptureDevice = AVCaptureDevice.default(for: .video) else { return } let videoInput: AVCaptureDeviceInput do { videoInput = try AVCaptureDeviceInput(device: videoCaptureDevice) } catch { return } if (captureSession.canAddInput(videoInput)) { captureSession.addInput(videoInput) } else { failed() return } let metadataOutput = AVCaptureMetadataOutput() if (captureSession.canAddOutput(metadataOutput)) { captureSession.addOutput(metadataOutput) metadataOutput.setMetadataObjectsDelegate(self, queue: DispatchQueue.main) metadataOutput.metadataObjectTypes = [.qr] } else { failed() return } previewLayer = AVCaptureVideoPreviewLayer(session: captureSession) previewLayer.frame = view.layer.bounds previewLayer.videoGravity = .resizeAspectFill view.layer.addSublayer(previewLayer) captureSession.startRunning() } func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection) { captureSession.stopRunning() if let metadataObject = metadataObjects.first { guard let readableObject = metadataObject as? AVMetadataMachineReadableCodeObject else { return } guard let stringValue = readableObject.stringValue else { return } AudioServicesPlaySystemSound(SystemSoundID(kSystemSoundID_Vibrate)) found(code: stringValue) } self.dismiss(animated: true, completion: nil) } func found(code: String) { Log.Info(code) } func failed() { captureSession = nil } override var prefersStatusBarHidden: Bool { return true } override var supportedInterfaceOrientations: UIInterfaceOrientationMask { return .portrait }As you can see from my code, I'm trying to get the camera window down after reading the `QR code`.But the camera screen is still on the frozen screen. No matter how long I wait, I can't see the web view screen. What's the problem?
Posted Last updated
.
Post not yet marked as solved
9 Replies
3.3k Views
I am using UIDocumentBrowser to retrieve files. But I am not able to place a back or cancel button in the navigation bar.I want to make a cancellation button for this but I can't make a cancellation button. How can I solve this problem?current code~~~swiftimport Foundation import UIKit @available(iOS 11.0, *) class DocumentBrowserViewController : UIDocumentBrowserViewController, UIDocumentBrowserViewControllerDelegate { override func viewDidLoad() { super.viewDidLoad() delegate = self browserUserInterfaceStyle = .dark view.tintColor = .white } func documentBrowser(_ controller: UIDocumentBrowserViewController, didRequestDocumentCreationWithHandler importHandler: @escaping (URL?, UIDocumentBrowserViewController.ImportMode) -> Void) { let newDocumentURL: URL? = nil // Set the URL for the new document here. Optionally, you can present a template chooser before calling the importHandler. // Make sure the importHandler is always called, even if the user cancels the creation request. if newDocumentURL != nil { importHandler(newDocumentURL, .move) } else { importHandler(nil, .none) } } func documentBrowser(_ controller: UIDocumentBrowserViewController, didPickDocumentURLs documentURLs: [URL]) { guard let sourceURL = documentURLs.first else { return } do{ try presentDocument(at: sourceURL) } catch { Log.Debug("\(error)") } } func documentBrowser(_ controller: UIDocumentBrowserViewController, didImportDocumentAt sourceURL: URL, toDestinationURL destinationURL: URL) { // Present the Document View Controller for the new newly created document do{ try presentDocument(at: sourceURL) } catch { Log.Debug("\(error)") } } func documentBrowser(_ controller: UIDocumentBrowserViewController, failedToImportDocumentAt documentURL: URL, error: Error?) { // Make sure to handle the failed import appropriately, e.g., by presenting an error message to the user. } func presentDocument(at documentURL: URL) throws { guard documentURL.startAccessingSecurityScopedResource() else { throw IXError.fileAcessFailed } let storyBoard = UIStoryboard(name: "Main", bundle: nil) let documentViewController = storyBoard.instantiateViewController(withIdentifier: "ViewController") as! ViewController documentViewController.document = Document(fileURL: documentURL) } }~~~picture of cancellation button that I wanthttps://ibb.co/KVT2qpj
Posted Last updated
.
Post marked as solved
1 Replies
2.8k Views
I am communicating through web view. My question is to send the pictures from the mobile phone to the web view.I call API here. I don't know how to send it to the web view. I know how to send only the Key,Value,which consists of a string.The code I'm taking pictures of phone.~~~swiftlet imagePicker: UIImagePickerController! = UIImagePickerController() let imagePicker: UIImagePickerController! = UIImagePickerController() var captureImage: UIImage! var flagImageSave = false @IBAction func btnLoadImageFromLibray(_ sender: UIButton) { if (UIImagePickerController.isSourceTypeAvailable(.photoLibrary)) { flagImageSave = false imagePicker.delegate = self imagePicker.sourceType = .photoLibrary imagePicker.mediaTypes = [kUTTypeImage as String] imagePicker.allowsEditing = true present(imagePicker, animated: true, completion: nil) }else{ myAlert("photo album inaccessable", message: "application cannot access the photo album") } } func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { let mediaType = info[UIImagePickerControllerMediaType] as! NSString if mediaType.isEqual(to: kUTTypeImage as NSString as String){ captureImage = info[UIImagePickerControllerOriginalImage] as! UIImage if flagImageSave { UIImageWriteToSavedPhotosAlbum(captureImage, self, nil, nil) } imgView.image = captureImage }else if mediaType.isEqual(to: kUTTypeMovie as NSString as String){ if flagImageSave { videoURL = (info[UIImagePickerControllerMediaURL] as! URL) UISaveVideoAtPathToSavedPhotosAlbum(videoURL.relativePath, self, nil, nil) } } self.dismiss(animated: true, completion: nil) }~~~API code being received by server on Sping Project~~~java@RequestMapping(value="/sendimage", method = RequestMethod.POST) public @ResponseBody Map<string, object=""> pr_image(HttpServletRequest webRequest , @RequestParam(value="image", required=false) MultipartFile image ) { Map<string, object=""> param = new HashMap<string, object="">(); Map<string, object=""> result = new HashMap<string, object="">(); Map<string, object=""> validationMap = ValidationUtils.ValidationOfKeys(webRequest); if (!validationMap.get("res").equals("sucess")) return validationMap; String num = (webRequest.getParameter("num") != null) ? webRequest.getParameter("num") : ""; String imagePath = ""; if (image != null) { String Extension = Config.USER_PROFILE_IMAGE_EXT; String fileName = "_" + Utils.getCurrentTime("yyyyMMddHHmmssSSS"); imagePath = Define.CONTENTS_FILE_PATH_4 + fileName + Extension ; File saveDir = new File(Define.CONTENTS_SAVE_PATH + Define.CONTENTS_FILE_PATH_4); if (!saveDir.isFile()) saveDir.mkdirs(); image.transferTo(new File(Define.CONTENTS_SAVE_PATH + imagePath)); String fileName_thumbnail = fileName + "_thumb" + Extension; File thumbnail = new File(Define.CONTENTS_SAVE_PATH + Define.CONTENTS_FILE_PATH_4 + fileName_thumbnail); thumbnail.getParentFile().mkdirs(); Thumbnails.of(saveDir + "/" + fileName + Extension).size(Config.USER_PROFILE_IMAGE_WIDTH, Config.USER_PROFILE_IMAGE_HEIGHT).outputFormat("jpg").toFile(thumbnail); }...~~~How can I transfer pictures with my data to spring server?I have to send not just images, but also numbers in strings. Look at my server code.
Posted Last updated
.