Post

Replies

Boosts

Views

Activity

Cannot find 'self' in scope
Hi! I'm trying to display a pdf inside my iOS app and I'm using the code displayed below, but for every self inside it I'm getting this error: Cannot find 'self' in scope // //  gimnaziumStundenplan.swift //  stundenplan // //  Created by Alex on 04/09/2021. // import UIKit import PDFKit private func createPdfView(withFrame frame: CGRect) -> PDFView {     let pdfView = PDFView(frame: frame)     pdfView.autoresizingMask = [.flexibleWidth, .flexibleHeight]     pdfView.autoScales = true     return pdfView } private func createPdfDocument(forFileName fileName: String) -> PDFDocument? {     if let resourceUrl = self.resourceUrl(forFileName: fileName) {         return PDFDocument(url: resourceUrl)     }          if let resourceUrl = URL(string: "https://web.stanford.edu/class/archive/cs/cs161/cs161.1168/lecture4.pdf") {             return PDFDocument(url: resourceUrl)         }         return nil } private func displayPdf() {     let pdfView = self.createPdfView(withFrame: self.view.bounds)     if let pdfDocument = self.createPdfDocument(forFileName: "heaps") {         self.view.addSubview(pdfView)         pdfView.document = pdfDocument     } } }
1
0
2.2k
Sep ’21
Display pdf inside swift ui
Hi! I'm creating an app for iOS and I want just to display a pdf from an external url with the width of 300 and height of 500. I tried with UiWebView but it is no longer supported. import SwiftUI let webView = UIWebView(frame: CGRect(x: 10, y: 10, width: 500, height: 300)) let targetURL = NSURL(string: "https://www.example.com/document.pdf")! let request = NSURLRequest(URL: targetURL) webView.loadRequest(request) struct StundenplanCard: View {     var body: some View {         VStack(spacing: 20) {             Text("Gimnazium") // here should be displayed the pdf         }     } } struct StundenplanCard_Previews: PreviewProvider {     static var previews: some View {         StundenplanCard().previewLayout(.fixed(width: 320, height: 640))     } }
1
0
1.8k
Sep ’21
An app just for a organisation
Hello, I am making an app for an organization, but I'm not 100% sure if it will meet all the requirements (my app is a few updating websites with news for the organization and I don't think that it will be accepted on the app store). Is there a way to get a link for my app (just to share in my organization), so my app doesn't need to be publicly available on the app store?
1
0
605
Nov ’21
Can't run Xcode project on iPhone
Hi, I'm trying to test an app on a iPhone and I get this error Unable to install "[app name]". If I click on the button "details", I get this: Unable to install "stundenplan" Domain: com.apple.dt.MobileDeviceErrorDomain Code: -402620375 -- The code signature version is no longer supported. Domain: com.apple.dt.MobileDeviceErrorDomain Code: -402620375 User Info: {     DVTRadarComponentKey = 261622;     MobileDeviceErrorCode = "(0xE8008029)";     "com.apple.dtdevicekit.stacktrace" = ( 0   DTDeviceKitBase                     0x000000012aaa5c8f DTDKCreateNSErrorFromAMDErrorCode + 220 1   DTDeviceKitBase                     0x000000012aae4241 __90-[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:]_block_invoke + 155 2   DVTFoundation                       0x000000010eca164b DVTInvokeWithStrongOwnership + 71 3   DTDeviceKitBase                     0x000000012aae3f82 -[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:] + 1440 4   IDEiOSSupportCore                   0x000000012a954a10 __118-[DVTiOSDevice(DVTiPhoneApplicationInstallation) processAppInstallSet:appUninstallSet:installOptions:completionBlock:]_block_invoke.292 + 3513 5   DVTFoundation                       0x000000010edd017e __DVT_CALLING_CLIENT_BLOCK__ + 7 6   DVTFoundation                       0x000000010edd1da0 __DVTDispatchAsync_block_invoke + 1191 7   libdispatch.dylib                   0x00007fff718076c4 _dispatch_call_block_and_release + 12 8   libdispatch.dylib                   0x00007fff71808658 _dispatch_client_callout + 8 9   libdispatch.dylib                   0x00007fff7180dc44 _dispatch_lane_serial_drain + 597 10  libdispatch.dylib                   0x00007fff7180e5d6 _dispatch_lane_invoke + 363 11  libdispatch.dylib                   0x00007fff71817c09 _dispatch_workloop_worker_thread + 596 12  libsystem_pthread.dylib             0x00007fff71a66a3d _pthread_wqthread + 290 13  libsystem_pthread.dylib             0x00007fff71a65b77 start_wqthread + 15 ); } -- System Information macOS Version 10.15.7 (Build 19H2) Xcode 12.4 (17801) (Build 12D4e) Timestamp: 2021-11-22T13:05:39+02:00 I'm testing on a iPhone 7 running iOS 15.1 from a MacBook Pro running macOS Catalina. Could the problem be the os compatibilities? NOTE: I can't update my MacBook OS because it's not compatible with newer versions.
1
0
1.6k
Nov ’21
Refresh tabItem view
Hello, I'm trying to show a pdf inside my app, using webkit, with the code below. When I open the app, everything is fine, but after I'm switching to another tab (another page), the content of the pdf doesn't show up (just the pages don't show up, but page counter is still there). view(request: URLRequest(url: URL(string: "[the url to the pdf file]")!)).previewLayout(.fixed(width: .infinity, height: .infinity)) .tabItem {     Image("Lyzeum")     Text("Lyzeum") } Also the URLRequest function: struct view : UIViewRepresentable {     let request: URLRequest     func makeUIView(context: Context) -> WKWebView  {         return WKWebView()     }     func updateUIView(_ uiView: WKWebView, context: Context) {         uiView.load(request)     } }
Topic: Safari & Web SubTopic: General Tags:
2
0
584
Nov ’21
Haptic feedback on tabItem click
Hi, I'm trying to add haptic feedback to a tabItem inside a tabView with this code (just a part of the ContentView file): @State private var tabSelection = 1     var body: some View {             TabView(selection: $tabSelection) {                 view(request: URLRequest(url: URL(string: "https://gnets.myds.me/stundenplan/gymnasium.php")!)).previewLayout(.fixed(width: .infinity, height: .infinity))                     .tabItem {                         Image("1")                         Text("Gymnasium")                     }.onTapGesture {                         self.tabSelection = 1                     }                 view(request: URLRequest(url: URL(string: "https://gnets.myds.me/stundenplan/lyzeum.php")!)).previewLayout(.fixed(width: .infinity, height: .infinity))                     .tabItem {                         Image("2")                         Text("Lyzeum")                     }.onTapGesture {                         self.tabSelection = 2                     }                 view(request: URLRequest(url: URL(string: "https://gnets.myds.me/stundenplan/nou/")!)).previewLayout(.fixed(width: .infinity, height: .infinity))                     .tabItem {                         Image("3")                         Text("Neuigkeiten")                     }.onTapGesture {                         self.tabSelection = 3                     }             }.onTapGesture {                 let impactLight = UIImpactFeedbackGenerator(style: .light)                 impactLight.impactOccurred()             }     } After testing on a iPhone, the haptic feedback acts in on click of a tabItem, and also on click of the entire view (which is fine), but the view (tab) doesn't change. (I added the variable tabSelection to make the tabItem force change the view, but it still doesn't work.) What I need is that on click of a tabItem, the view changes (as normal), but also gets a light haptic feedback.
0
0
1.3k
Dec ’21
Does App Store Review accept WebKit Websites?
Hi! I'm just starting out with making iOS app and I want to publish my first app, but before I pay 99$ for the Apple Developer Program, I want to know if the App Store Review accepts WebKit Websites with the following code: import SwiftUI import WebKit struct view : UIViewRepresentable {     let request: URLRequest     func makeUIView(context: Context) -> WKWebView  {         return WKWebView()     }     func updateUIView(_ uiView: WKWebView, context: Context) {         uiView.load(request)     } } struct ContentView: View {     var body: some View {             TabView {                 view(request: URLRequest(url: URL(string: "https://gnets.myds.me/cloud/gymnazium.pdf")!)).previewLayout(.fixed(width: .infinity, height: .infinity))                     .tabItem {                         Image("1")                         Text("Gymnasium")                     }                 view(request: URLRequest(url: URL(string: "https://gnets.myds.me/cloud/lyzeum.pdf")!)).previewLayout(.fixed(width: .infinity, height: .infinity))                     .tabItem {                         Image("2")                         Text("Lyzeum")                     }                 view(request: URLRequest(url: URL(string: "https://gnets.myds.me/stundenplan/nou/")!)).previewLayout(.fixed(width: .infinity, height: .infinity))                     .tabItem {                         Image("3")                         Text("Neuigkeiten")                     }             }     } } struct ContentView_Previews : PreviewProvider {     static var previews: some View {         ContentView()     } }
2
0
1.3k
Jan ’22
Send notification if content of a website has changed
Hi, I'm building an app for a organisation that requires to send a notification every time the content of a website changes (the website updates). (There is a list of news that are displayed into a webkit view.) I could do it with APNs, but I think it is too complicated for just a simple task like this. I tried with user notification, but I don't know how to store a small copy of the website and every day check if the copy and the website are the same. If they are not the same, a notification should be pushed. Could anyone help? Thank you, Alex Sofonea
1
0
1k
Jan ’22
Cannot create signature for JWT for APNs
I am trying to generate the signature for a JWT using a .p8 private key from Apple for APNs in PHP. If I try to use the following command hash_hmac('sha256', $header . '.' . $payload, $key), when checking it in Apple's JSON Web Token Validator, I get that the signature is invalid. I have also tried converting the .p8 private key to a PEM file and importing it into the OpenSSL library, but I am still getting the error message openssl_sign(): Supplied key param cannot be coerced into a private key. But I generate the JWT using Apple's JSON Web Token Generator, everything goes well, even the request to APNs. Thank you in advance!
1
0
1.1k
Sep ’23