Posts

Post not yet marked as solved
0 Replies
169 Views
I create a UIViewRepresentable to show my PDF inside my SwiftUI app. I want to access the current page number using currentPage?.pageRef?.pageNumber. from the view in which I display the pdf. How to make PDFView Created in func makeUIView(context: UIViewRepresentableContext<PDFDisplayRepresentedView>) -> PDFView Available in the view displaying the pdf so I can access its properties to obtain page number. import SwiftUI import PDFKit struct PDFDisplayView: View { @Binding var pdfDocument : PDFDocument? var body: some View { PDFDisplayRepresentedView(pdfDocument: pdfDocument!) } } struct PDFDisplayRepresentedView: UIViewRepresentable { let pdfDocument: PDFDocument init(pdfDocument: PDFDocument) { self.pdfDocument = pdfDocument } func makeUIView(context: UIViewRepresentableContext<PDFDisplayRepresentedView>) -> PDFView { return createPDFViewUsing(document: pdfDocument) } func updateUIView(_ pdfView: PDFView, context: UIViewRepresentableContext<PDFDisplayRepresentedView>) { pdfView.document = pdfDocument } private func createPDFViewUsing(document : PDFDocument) -> PDFView { let pdfView = PDFView(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) pdfView.document = document ... set up pdfView attributes return pdfView } } view showing pdf where I want to know the page number pseudo code … @State private var pdfDisplayView : PDFDisplayView? …. var body: some View { load the pdf into this view. need to access the page number pdfDisplayView }
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
0 Replies
966 Views
From the Internet I read that URLRequest sends an Accept-Encoding header by default. I also read that URLSession auto decompresses any data that’s returned compressed. However these are what the internet says. I go to the Apple docs and read the URLSession &amp; URLRequest sections but I can’t find where does it say that it sends the Accept-Encoding headers by default or that it auto decompresses compressed data. I know it does the latter as I am able to parse compressed data and have to do nothing to decompress. Just tell me where this stuff is documented by Apple so I can read about it.
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
1 Replies
2k Views
I use UIHostingController inside my UIViewController to present a SwiftUI View. I have a button in that view which I want to tap and dismiss the presented view. How do I dimiss SwiftUI views when presented in a UIHostingController...{ let vc = UIHostingController(rootView: SwiftUIView()) present(vc, animated: true, completion: nil) }struct SwiftUIView : View { var body: some View { CustomButton() } }struct CustomButton: View { var body: some View { Button(action: { self.buttonAction() }) { Text(buttonTitle) } } func buttonAction(){ //dismiss the SwiftUIView when this button pressed } }
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
0 Replies
108 Views
Big Sur Beta 5 won't install for me or many others it seems. I'm on a 2017 iMac 5k. The iOS 14 betas have been absolutely terrible and my 3rd gen Apple Watch claims I have to delete files in order to install the latest beta on that. I have 0 songs, 15 phantom photos (no idea how to get rid of those) and just 6 apps. The update needs 2.9GB of space and despite having nothing on the watch really I only have 2.7GB free. There is no way for me to even clear some more space. I wouldn't mind or complain if I wasn't paying apple $99 to be a developer. Not to mention the thousands of $$ paid for the hardware. The very minimum we deserve is these betas are actually able to be installed.
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
2 Replies
365 Views
In iOS when a button can be actioned it is coloured accordingly so the user knows to tap. This is a standard across the platform. Is there a standard for long press gestures? In the case of swiftUI the 3D Touch/ long press can show a contextMenu. How best to indicate to a user to long press? Is there a standard colour for example to show when an element is to be long pressed?
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
2 Replies
366 Views
Since iOS 13 (including all recent betas) if a PDF page should have a background colour that colour isn’t showing and instead the page is white. I’m displaying the page with the PDFKit framework. I’ve also noticed that this is occurring in Apples own apps too like iBooks so no point posting code as it’s not my code specific. I’ve also noticed this only seems to happen for some users so appears to be either device specific or some other attribute. Has anyone here found this and indeed a solution ?
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
0 Replies
553 Views
I have multiple CustomTextFields and when they are actively being edited I want to know which one is currently active. I have set tags but you can not reference the tag inside the onEditingChanged closure. struct CustomTextField : View { var placeHolderString : String @Binding var contentString. : String var body : some View { TextField(placeHolderString, text: $contentString, onEditingChanged: { (editing) in //Determin which TextField is currently active here }, onCommit: { }).textFieldStyle(RoundedBorderTextFieldStyle()) .multilineTextAlignment(.center) } }
Posted
by RyanTCB.
Last updated
.
Post marked as solved
1 Replies
1.1k Views
I have a 3 TextFields in SwiftUI. one on top and two side by side underneath that.VStack{ //TF1 TextField("Duty", text: $dutyNumber) .textFieldStyle(RoundedBorderTextFieldStyle()) .padding([.leading], 50) .multilineTextAlignment(.center) .keyboardType(.numberPad) HStack{ //TF2 TextField("Start time", text: $dutyStartTime) .textFieldStyle(RoundedBorderTextFieldStyle()) .padding([.leading], 50) .multilineTextAlignment(.center) .keyboardType(.numberPad) //TF3 TextField("Finish time", text: $dutyFinishTime) .textFieldStyle(RoundedBorderTextFieldStyle()) .padding([.leading], 50) .multilineTextAlignment(.center) .keyboardType(.numberPad) } }However only the last textfield TF3 is interactive. Cannot select the first two TF1 &amp; TF2. Can Tab into them with keyboard but cannot select them with a finger tap. If I change the order from TF1, TF2, TF3 to TF1, TF3, TF2 for example. Then TF2 is now interactive but TF1 &amp; TF3 are not. Is this a bug with adding multiple TextFields in SwiftUI or am I missing something obvious?
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
2 Replies
550 Views
In iOS 13 the titles on my UISegmeted contols are misaligned and appear very top left corner. When they should be the center default. if this was a better forum i could include screenshots. Is this behaviour seen by anyone else ?
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
12 Replies
7k Views
When I run my App with xCode all loads and runs fine. When I load in Instruments and press record using a profiling template of Activity Monitor or Allocations it loads and runs fine. However if I use Zombies or Leaks the app crashes instantly. I dont even get to see it. I then access the crash logs in xcode and thought the reason for the crash isException Type: EXC_BAD_ACCESS (SIGSEGV)Its almost impossible to debug as wach report is different.Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000010 VM Region Info: 0x10 is not in any region. Bytes before following region: 4297687024 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---&gt; __TEXT 0000000100298000-0000000100388000 [ 960K] r-x/r-x SM=COW ...p/MyApp Termination Signal: Segmentation fault: 11 Termination Reason: Namespace SIGNAL, Code 0xb Terminating Process: exc handler [0] Triggered by Thread: 0 Filtered syslog: None found Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libswiftFoundation.dylib 0x0000000100cf89fc 0x100c4c000 + 707068 1 MyApp 0x0000000100310cbc specialized JSONParser.jsonURL(_:jsonType:) + 494780 (JSONParser.swift:51) 2 MyApp 0x0000000100310cbc specialized JSONParser.jsonURL(_:jsonType:) + 494780 (JSONParser.swift:51) 3 MyApp 0x00000001002efd2c StoreManager.getProductIdentifiersFromServer() + 359724 (StoreManager.swift:57) 4 MyApp 0x0000000100329db0 specialized AppDelegate.application(_:didFinishLaunchingWithOptions:) + 597424 (StoreManager.swift:46) 5 MyApp 0x0000000100326a40 @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) + 584256 (AppDelegate.swift:0) 6 UIKit 0x000000018f4a1ca8 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 408 7 UIKit 0x000000018f68fe14 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3484 8 UIKit 0x000000018f694ce4 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1680 9 UIKit 0x000000018f92db20 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 784 10 UIKit 0x000000018fc05c78 +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 160 11 UIKit 0x000000018f92d79c -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 240 12 UIKit 0x000000018f92dfdc -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 724 13 UIKit 0x00000001900accf4 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 296 14 UIKit 0x00000001900acb7c -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 432 15 UIKit 0x000000018fe1f44c __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 220 16 UIKit 0x000000018ffb5c5c _performActionsWithDelayForTransitionContext + 112 17 UIKit 0x000000018fe1f304 -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 248 18 UIKit 0x000000018fc05318 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 368 19 UIKit 0x000000018f6933e4 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 540 20 UIKit 0x000000018faa7490 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 364 21 FrontBoardServices 0x00000001878d7470 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 364 22 FrontBoardServices 0x00000001878dfd6c __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 224 23 libdispatch.dylib 0x00000001849f0ae4 _dispatch_client_callout + 16 24 libdispatch.dylib 0x00000001849f81f4 _dispatch_block_invoke_direct$VARIANT$mp + 224 25 FrontBoardServices 0x000000018790b878 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36 26 FrontBoardServices 0x000000018790b51c -[FBSSerialQueue _performNext] + 404 27 FrontBoardServices 0x000000018790bab8 -[FBSSerialQueue _performNextFromRunLoopSource] + 56 28 CoreFoundation 0x0000000185099614 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 29 CoreFoundation 0x0000000185098e3c __CFRunLoopDoSources0 + 276 30 CoreFoundation 0x00000001850969ac __CFRunLoopRun + 1204 31 CoreFoundation 0x0000000184fb6fe8 CFRunLoopRunSpecific + 552 32 GraphicsServices 0x0000000186f7e020 GSEventRunModal + 100 33 UIKit 0x000000018f497090 UIApplicationMain + 236 34 MyApp 0x00000001002ab444 main + 78916 (AppDelegate.swift:16) 35 libdyld.dylib 0x0000000184a55fc0 start + 4So I stop calling the lineStoreManager.getProductIdentifiersFromServer()which stops the subsequent calls toJSONParser.jsonURL(_:jsonType:)Then the app crashesException Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000 VM Region Info: 0 is not in any region. Bytes before following region: 4365631488 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---&gt; __TEXT 0000000104364000-0000000104454000 [ 960K] r-x/r-x SM=COW ...p/MyApp Termination Signal: Segmentation fault: 11 Termination Reason: Namespace SIGNAL, Code 0xb Terminating Process: exc handler [0] Triggered by Thread: 0 Filtered syslog: None found Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 CoreFoundation 0x0000000184fdf83c CFStringGetCharacterAtIndex + 24 1 CoreFoundation 0x000000018508e6c8 normalizeQuintuplet + 148 2 CoreFoundation 0x000000018508ee64 -[_CFXPreferences+ 917092 (SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:] + 108 3 CoreFoundation 0x0000000185132ae8 -[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:] + 124 4 CoreFoundation 0x0000000185135384 _CFPreferencesCopyAppValueWithContainer + 116 5 Foundation 0x0000000185a2e7d0 -[NSUserDefaults+ 51152 (NSUserDefaults) objectForKey:] + 52 6 Foundation 0x0000000185a37240 -[NSUserDefaults+ 86592 (NSUserDefaults) stringForKey:] + 24 7 MyApp 0x00000001043cc0dc specialized SettingsTableViewController.init(coder:) + 426204 (SettingsTableViewController.swift:36) 8 MyApp 0x00000001043c6a1c @objc SettingsTableViewController.init(coder:) + 403996 (SettingsTableViewController.swift:27) 9 UIKit 0x000000018f9c051c -[UIClassSwapper initWithCoder:] + 248 10 UIKit 0x000000018fb6d99c UINibDecoderDecodeObjectForValue + 688 11 UIKit 0x000000018fb6d6d4 -[UINibDecoder decodeObjectForKey:] + 312 12 UIKit 0x000000018f9c01c4 -[UIRuntimeConnection initWithCoder:] + 188 13 UIKit 0x000000018fb6d99c UINibDecoderDecodeObjectForValue + 688 14 UIKit 0x000000018fb6db14 UINibDecoderDecodeObjectForValue + 1064 15 UIKit 0x000000018fb6d6d4 -[UINibDecoder decodeObjectForKey:] + 312 16 UIKit 0x000000018f9bf514 -[UINib instantiateWithOwner:options:] + 1164 17 UIKit 0x000000018fd44068 -[UIStoryboard instantiateViewControllerWithIdentifier:] + 196 18 MyApp 0x00000001043fcfb4 specialized ApplicationsTabBarController.createViewControllerForTabBarController(storyBoardName:restorationIdentifier:tabBarItemTitle:tabBarItemTag:tabBarItemImage:tabBarItemSelectedImage:) + 626612 (ApplicationsTabBarController.swift:190) 19 MyApp 0x00000001043f93c8 ApplicationsTabBarController.setUpViewControllers() + 611272 (ApplicationsTabBarController.swift:79) 20 MyApp 0x00000001043fad04 @objc ApplicationsTabBarController.viewWillAppear(_:) + 617732 (ApplicationsTabBarController.swift:0) 21 UIKit 0x000000018f44c6b4 -[UIViewController _setViewAppearState:isAnimating:] + 616 22 UIKit 0x000000018f44c424 -[UIViewController __viewWillAppear:] + 140 23 UIKit 0x000000018f4aba60 -[UIViewController viewWillMoveToWindow:] + 704 24 UIKit 0x000000018f43bde4 -[UIView+ 97764 (Hierarchy) _willMoveToWindow:withAncestorView:] + 584 25 UIKit 0x000000018f43b0cc -[UIView+ 94412 (Internal) _addSubview:positioned:relativeTo:] + 424 26 UIKit 0x000000018f43a88c -[UIWindow addRootViewControllerViewIfPossible] + 816 27 UIKit 0x000000018f437864 -[UIWindow _setHidden:forced:] + 272 28 UIKit 0x000000018f4a5cd0 -[UIWindow makeKeyAndVisible] + 48 29 MyApp 0x00000001043f639c specialized AppDelegate.application(_:didFinishLaunchingWithOptions:) + 598940 (AppDelegate.swift:0) 30 MyApp 0x00000001043f2bc4 @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) + 584644 (AppDelegate.swift:0) 31 UIKit 0x000000018f4a1ca8 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 408 32 UIKit 0x000000018f68fe14 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3484 33 UIKit 0x000000018f694ce4 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1680 34 UIKit 0x000000018f92db20 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 784 35 UIKit 0x000000018fc05c78 +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 160 36 UIKit 0x000000018f92d79c -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 240 37 UIKit 0x000000018f92dfdc -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 724 38 UIKit 0x00000001900accf4 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 296 39 UIKit 0x00000001900acb7c -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 432 40 UIKit 0x000000018fe1f44c __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 220 41 UIKit 0x000000018ffb5c5c _performActionsWithDelayForTransitionContext + 112 42 UIKit 0x000000018fe1f304 -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 248 43 UIKit 0x000000018fc05318 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 368 44 UIKit 0x000000018f6933e4 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 540 45 UIKit 0x000000018faa7490 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 364 46 FrontBoardServices 0x00000001878d7470 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 364 47 FrontBoardServices 0x00000001878dfd6c __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 224 48 libdispatch.dylib 0x00000001849f0ae4 _dispatch_client_callout + 16 49 libdispatch.dylib 0x00000001849f81f4 _dispatch_block_invoke_direct$VARIANT$mp + 224 50 FrontBoardServices 0x000000018790b878 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36 51 FrontBoardServices 0x000000018790b51c -[FBSSerialQueue _performNext] + 404 52 FrontBoardServices 0x000000018790bab8 -[FBSSerialQueue _performNextFromRunLoopSource] + 56 53 CoreFoundation 0x0000000185099614 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 54 CoreFoundation 0x0000000185098e3c __CFRunLoopDoSources0 + 276 55 CoreFoundation 0x00000001850969ac __CFRunLoopRun + 1204 56 CoreFoundation 0x0000000184fb6fe8 CFRunLoopRunSpecific + 552 57 GraphicsServices 0x0000000186f7e020 GSEventRunModal + 100 58 UIKit 0x000000018f497090 UIApplicationMain + 236 59 MyApp 0x0000000104378b3c main + 84796 (AppDelegate.swift:16) 60 libdyld.dylib 0x0000000184a55fc0 start + 4Does not seem to matter what functions I do or do not call I get a crash. It seems to me that its a system call and not one that I make thats causing the crash. Is it just me or is Instruments 9.3 crashing on Zombies and Or Leaks for anyone else?
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
1 Replies
987 Views
I have a loop that iterates all pages in a PDF and saves parts of its content into core data. Problem seems to be that each PDFPage takes up around 30mb+ of memory. This memory is not retuned when the loop moves to ther next page. with large enough PDF in can cause out of memory crash.At first I thought it was something in the loop holidng a reference. However when I dont run the loop, or attempt to save any of the PDFPage contents and simply swipe through the PDFPages of the PDF, the memory still goes up 30mb + per page. So my question is how to clear the previous page from memory when no longer the page in view?I would add code but seems you cant pste into here so jist know its basic PDFKit code to load a pdf url
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
0 Replies
293 Views
If I show a prompt on a NavigationControllerself.navigationController?.navigationBar.topItem?.prompt = "something to prompt"The self.navigationController?.navigationBar.topItem ... barButtonItems, stop working. They don't even indicate with teh standard animation that they are being touched. Is this epected behaviour or bug
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
1 Replies
592 Views
I need a sticky header so in ViewDidLoad I set,let layout = collectionView?.collectionViewLayout as? UICollectionViewFlowLayout layout?.sectionHeadersPinToVisibleBounds = trueThen I have a button that scrolls the UICollectionViewCell to the top using//todayIndexpath is and IndexPath set from cellForRowAt if let indexP = todayIndexpath { collectionView?.scrollToItem(at: indexP, at: UICollectionViewScrollPosition.top, animated: true) }unfortunately the cell that scrolls to the top also goes behind the section header. so it sis obstructed. I need to scroll so the cell at the indexpath scrolls to the top but underneath the header. Would have thought that UICollectionViewScrollPosition.top would take into account the header as when the view first loads its underneath it so must know its there.Is there a fix?
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
0 Replies
491 Views
in 11.2 we get access to the SKProductSubscriptionPeriod. An enum that lets us retieve the length of a products subscrption.The enum has a day case. Yet in iTunesConnect we do not. We also have other lengths available in itunesConnect (6 months for example) that are excluded from the enum. Question is will iTunesConnect change to only allow subscription period declared in the enum or vice versa?public enum PeriodUnit : UInt { case day case week case month case year }
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
3 Replies
1.9k Views
So PDFView allows setting the PDFViews scrollView to a UIPageViewController withusePageViewController(_:withViewOptions:)Q1. How can I access the PDFViews pageViewController so I can set myself as its delegate so I can receivepageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool)Q2. how can I change the UIPageViewControllerTransitionStyle of PDFView when usePageViewController(_:withViewOptions:) is called?
Posted
by RyanTCB.
Last updated
.