I recently observed a distinction in the lookup behavior for an Asset within a specific Bundle when using UIImage.init(named:in:compatibleWith:) compared to Image.init(_:bundle:).
Consider a scenario where we have an asset named camera, and there is also an SF symbol with the name camera.fill.
We also have an Asset in our Swift Package and use its Bundle. In that case .module.
Now, when we use UIImage.init(named:in:compatibleWith:) and inject camera.fill and .module, the result of this initialization is not nil. It appears that UIImage has located something within our Asset.
On the other hand, when we inject camera.fill into Image.init(_:bundle:) using the same bundle, the result of this initialization is an empty Image, accompanied by a log entry stating: "No image named 'camera.fill' found in the asset catalog for /Users/.../.bundle." This behaviour aligns with expectations, as we don't have an explicitly named camera.fill within our Assets inside the bundle .module.
It appears that even though we injected camera.fill into UIImage.init(named:in:compatibleWith:), it found the first best match, in this case, the camera Asset. Meanwhile, Image.init(_:bundle:) found nothing explicitly named camera.fill within our Assets.
Doesn't it seem logical for both of these APIs to yield the same result? Perhaps, it would be even better if both APIs looked up the given name consistently, taking into account the provided bundle in the same way.
UIKit
RSS for tagConstruct and manage graphical, event-driven user interfaces for iOS or tvOS apps using UIKit.
Post
Replies
Boosts
Views
Activity
In my Iphone app, I want to open json files that I have earlier saved. The function I mention below to open the file is not firing when I share a file to my app.
I have implemented this in the info.plist file and this seems to work, because in Files I can share a .json file to may app.
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>JSON Document</string>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>LSItemContentTypes</key>
<array>
<string>public.json</string>
</array>
</dict>
</array>
I have added the function to open the file in my AppDelegate file.
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
// Handle the file at the given URL
// You can perform actions based on the file type or content
print("Opening file!")
}
(the implementation is actually longer to work on the file).
When I share a file to my app, the app itself is opening but this method 'application' is never called.
I'm not sure whether I'm overlooking something. I have searched quite a while to see what I'm missing.
Any help is greatly appreciated!
Emile
Here is the set up.
I have a UITableViewController (controller 1), to which I get from a controller (0)
As I need to add a searchView atop the tableView, I addSubview to the superview.
This is done in viewWillAppear
self.view.superview?.addSubview(searchView) // AboveTableView
searchView.isHidden = true
print("willAppear", self.view.superview, self.tableView.superview)
It works perfectly well, I get:
willAppear Optional(<UIViewControllerWrapperView: 0x103d2eef0; frame = (0 0; 393 852); autoresize = W+H; layer = <CALayer:
From this VC, I segue to another VC (2) with a show segue and comes back with an unwindSegue to return to (1).
Problem is that no, superviews are nil.
@IBAction func unwindToTableViewController(_ sender: UIStoryboardSegue) {
print("unwind", self.view.superview, self.tableView.superview)
}
gives
unwind nil nil
If I step back from this controller (1) to the controller (0) from which I segued and segue again to the TableViewController (1), everything works as expected.
In addition, if I go from 1 -> 2 by instantiating (2), everything works OK when I unwind to (1).
I know a solution is to refactor code replacing UITableViewController with a UIViewController and embed a TableView inside. But I would like to understand why my present design does not work.
I have a view in storyboard, with a tableView and a coloured UIView.
The UIView is declared after tableView, so it appears on top of tableView.
However, it appears semi transparent over the tableView.
In addition, I cannot set its alpha channel to values other than 1 or 0 (e.g., 0.9)
But if I create the view programmatically, the view if fully opaque as expected.
What am I missing ?
Situation
I am implementing a filter view that has a button to apply the filters selected. The button shows how many results applying the current filters would yield.
Like this:
The label contains the count variable, the expectation is that when the count updates the button will reflect the new number of results.
Current setup
I am passing the data (count displayed in the button) like this: ViewModel -> View (SwiftUI) -> View (SwiftUI) -> UIViewControllerRepresentable -> UIViewController.
I have validated that the variable that holds the count updates whenever a filter is selected, but the button is not re-rendered to display the new value.
Here are some simplified code snippets (In the order described above):
ViewModel:
@MainActor class ViewModel: ObservableObject {
@Published var resultCount: Int = 0
@Published var status: String = ""
@Published var type: String = ""
init(){
self.addSubscribers()
})
}
func addSubscribers() {
// code here used to filter uses sink based on filters (status and type) selected, this will update resultCount
}
}
ContainerView:
struct ContainerView: View {
@EnvironmentObject private var vm: ViewModel
var body: some View {
VStack {
FilterView(status: $vm.status, type: $vm.type, resultCount: $vm.resultCount)
}
}
}
FilterView:
struct FilterView: View {
@Binding var status: String
@Binding var type: String
@Binding var resultCount: Int
var body: some View {
VStack {
FormViewControllerRepresentable(status: $status, type: $type, resultCount: $resultCount, showFilterSelectionView: $showFilterSelectionView)
}
}
}
FormViewControllerRepresentable:
struct FormViewControllerRepresentable: UIViewControllerRepresentable {
@Binding var status: String
@Binding var type: String
@Binding var resultCount: Int
func makeUIViewController(context: Context) -> FilterFormViewController {
FilterFormViewController(status: $status, type: $type, resultCount: $resultCount)
}
func updateUIViewController(_ uiViewController: FilterFormViewController, context: Context) {
uiViewController.status = status
uiViewController.type = type
uiViewController.resultCount = resultCount
}
}
UIViewController
class FilterFormViewController: UIViewController, UITextFieldDelegate {
@Binding var status: String
@Binding var type: String
@Binding var resultCount: Int
@Binding var showFilterSelectionView: Bool
init(status: Binding<String>, type: Binding<String>, resultCount: Binding<Int>, showFilterSelectionView: Binding<Bool>) {
self._status = status
self._type = type
self._resultCount = resultCount
self._showFilterSelectionView = showFilterSelectionView
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
lazy var formView = Form()
let stackView = UIStackView()
let scrollView = UIScrollView()
override func viewDidLoad() {
super.viewDidLoad()
setup()
}
func setup() {
// set delegate for Picker (filters)
formView.statusPicker.textField.delegate = self
formView.statusPicker.delegate = self
formView.typePicker.textField.delegate = self
formView.typePicker.delegate = self
stackView.addArrangedSubview(getButtonsStackView())
scrollView.addSubviews([stackView])
view.addSubview(scrollView)
}
func getButtonsStackView() -> UIStackView {
// HERE is the button. even though resultCount updates, the button is not re-rendered
// UIButton here is actually a custom component that conforms to UIButton. In the custom component setTitle(label, for: .normal) is called
let submitButton = UIButton( label: "Show \(self.resultCount) results")
submitButton.isEnabled = true
submitButton.addTarget(self, action: #selector(hideFilters), for: .touchUpInside)
let buttonsView = UIStackView(
arrangedSubviews: [
submitButton
]
)
return buttonsView
}
func textFieldDidEndEditing(_ textField: UITextField) {
// getters here are working well and setting the value for status & type is updating the variable in the viewModel
// THE PROBLEM IS: While this updates the value for the filters and that in turns updates the result count, the button won't re-render with the new value
status = formView.getStatus()
type = formView.getType()
}
}
Hey Team,
We started to get the NSInternalInconsistencyException crash only for iOS 17. The crash logs are very generic and don’t point to any specific screen or code that’s why it's hard to figure out the root cause for this. We already tried running the main thread checker but we didn’t get any thread issues.
Kindly help.
Crash Logs:
Fatal Exception: NSInternalInconsistencyException
Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.
0 CoreFoundation 0xec870 __exceptionPreprocess
1 libobjc.A.dylib 0x2bc00 objc_exception_throw
2 CoreAutoLayout 0x56c8 NSISSparseVectorAddTermWithPlaceValueCoefficientStartingIndex
3 CoreAutoLayout 0xbadc -[NSISEngine _optimizeWithoutRebuilding]
4 CoreAutoLayout 0xb7f0 -[NSISEngine optimize]
5 CoreAutoLayout 0xb57c -[NSISEngine performPendingChangeNotifications]
6 UIKitCore 0x33f38 -[UIView(Hierarchy) layoutSubviews]
7 UIKitCore 0x32694 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
8 QuartzCore 0x671c0 CA::Layer::layout_if_needed(CA::Transaction*)
9 QuartzCore 0x66d48 CA::Layer::layout_and_display_if_needed(CA::Transaction*)
10 QuartzCore 0x6d278 CA::Context::commit_transaction(CA::Transaction*, double, double*)
11 QuartzCore 0x66574 CA::Transaction::commit()
12 QuartzCore 0x1fe504 CA::Transaction::release_thread(void*)
13 libsystem_pthread.dylib 0x9f48 _pthread_tsd_cleanup
14 libsystem_pthread.dylib 0x4880 _pthread_exit
15 libsystem_pthread.dylib 0x5d7c _pthread_wqthread_legacy_worker_wrap
16 libsystem_pthread.dylib 0x19ec _pthread_wqthread
17 libsystem_pthread.dylib 0x1a04 start_wqthread
Hi guys,
I am developing an app which is a messaging app and it needs to work smoothly.
However, I ran into an issue where I couldn't scroll over RTL text properly. It doesn't matter whether I am using UIKit or SwiftUI it just stutters.
I tested out on an iPad with a promotion display / iPhone XS and 15 pro-Max and the result was the same.
Someone said using an RTL font could resolve the issue however it did not.
And if you uncomment the line 48 and comment the line 49 you will see the app run smoothly without a hitch.
It is overtly clear in messaging apps that the app stutters, and our users have complained about it a lot.
struct UItableViewTest: View {
var body: some View {
SwiftUI.NavigationStack {
NavigationLink {
RandomItemsTableViewControllerWrapper()
} label: {
Text("move to table view controller")
}
}
}
}
struct RandomItemsTableViewControllerWrapper: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
return RandomItemsTableViewController()
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}
class RandomItemsTableViewController: UITableViewController {
private let cellReuseIdentifier = "Cell"
private var items: [String] = []
private let font = UIFont(name: "RTLFONT", size: 16)
override func viewDidLoad() {
super.viewDidLoad()
generateRandomItems()
tableView.register(UITableViewCell.self, forCellReuseIdentifier: cellReuseIdentifier)
}
private func generateRandomItems() {
let maxRTLLength = MockTexts.rtlText.count
let numberOfItems = 100
for _ in 0..<numberOfItems {
let randomLength = Int.random(in: 10...maxRTLLength)
let randomRTL = Bool.random()
// let randomText = String(MockTexts.loremIpsum.prefix(randomLength))
let randomText = String(randomRTL ? MockTexts.rtlText.prefix(randomLength) : MockTexts.loremIpsum.prefix(randomLength))
items.append(randomText)
}
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: cellReuseIdentifier, for: indexPath)
cell.textLabel?.text = items[indexPath.row]
cell.textLabel?.numberOfLines = 0
cell.textLabel?.font = font
return cell
}
}
#Preview {
UItableViewTest()
}
struct MockTexts {
static let loremIpsum = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed commodo gravida sagittis.\n Nulla facilisi. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; \n Nam eleifend metus leo, id maximus ante posuere ac.\n Fusce ultrices fringilla malesuada.\n Sed eget lectus ut nisl condimentum scelerisque.\n Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed commodo gravida sagittis.\n Nulla facilisi. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; \n Nam eleifend metus leo, id maximus ante posuere ac.\n Fusce ultrices fringilla malesuada.\n Sed eget lectus ut nisl condimentum scelerisque.\n Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed commodo gravida sagittis.\n Nulla facilisi. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; \n Nuada.\n Sed eget lectus ut nisl condimentum scelerisque.\n Pellentesque habit
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed commodo gravida sagittis.\n Nulla facilisi. Vesti
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed commodo gravida sagittis.\n Nulla facilisi. Vestiabitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed commodo gravida sagittis.\n Nulla facilisi. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; \n Nam eleifend metus leo, id maximus ante posuere ac.\n Fusce ultrices fringilla malesuad\n
te ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; \n Nam eleifend metus leo, id maximus ante posuere ac.\n Fusce ultrices fringilla malesuada.\n Sed eget lectus ut nisl condimentum scelerisque.\n Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
"""
static let rtlText = """
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
سلام این یه متن طولانی است که من برای تست دارم می نویسم ببینم چه جوری کار میکنه متن های خیلی طولانی فارسی.
"""
}
How can I use this code in ContentView with the default augmented reality template provided by Xcode
Hey guys, I hope you are all doing well! I am really stuck on a problem and I need help here. I am new to Swift but I need to use Swift to complete a project. I am trying to use this code https://github.com/jmousseau/RoomObjectReplicatorDemo/blob/main/RoomObjectReplicatorDemo/ViewController.swift with the RoomObjectReplicator library https://github.com/jmousseau/RoomObjectReplicator. However, the issue is that my app is currently using SwiftUI and not UIKit. Furthermore, I have ContentView and ARViewContainer. How can I implement the code but use ContentView and ARViewContainer along with SwiftUI? Thanks in advance!
Hi, I've got this html text:
"<style>* {font-size: 12pt !important;color: #000000 !important;font-family: Montserrat-Regular !important;}</style>Perform the following steps:<br><u>Option 1:</u><br><p>1) Upon receiving a push notification alert, tap on the push notification to launch BIMB Authenticator</p><p>2) Verify the transaction details and choose \"Approve\"</p><p>3) Complete</p><br><u>Option 2:</u><br><ol><p>1) If you didn’t receive push notification, you may launch BIMB Authenticator</p><p>2) Verify the transaction details and choose \"Approve\"</p><p>3) Complete</p>"
And I'm trying to show this HTML text properly in a UILabel. This is my codes:
String extension to map to NSAttributedString:
extension String {
func attributedStringFromHTML() -> NSAttributedString? {
guard let data = "\(self)"
.data(using: .utf8, allowLossyConversion: false) else {
Log.error(category: .transaction, message: "Unable to decode data from html string: %@", self)
return nil
}
let options: [NSAttributedString.DocumentReadingOptionKey: Any] = [
.documentType: NSAttributedString.DocumentType.html,
.characterEncoding: String.Encoding.utf8.rawValue
]
if let attributedString = try? NSAttributedString(data: data, options: options, documentAttributes: nil) {
return attributedString
} else {
Log.error(category: .transaction,
message: "Unable to create attributed string from html string: %@",
self)
return nil
}
}
}
And this is the result:
Can you tell me how to fix this? Thanks.
Anyone knows about any workarounds for this crash "Spatial presentations are not permitted from popovers."
Hi!
How i can set cornerRadius to UIContextualAction element without any frameworks in UIKit?
Now i found way to set image or title to this action.
I want to use uitableview in tvos to show list of string data but compiler is throughing following errors in generated header:
"No type or protocol named 'UITableViewDataSource'"
And "Attempting to use the forward class 'UITableView' as superclass of 'TWOSSelectionTableTVOS'"
Even though this code is working is ios .
My code structure is as follow :
SelectionTable.swift:
import UIKit
class TWOSSelectionTableTVOS : UITableView
{
private var vDataSrc:[String]!
func SetDataSrc (_ pDataSrc:[String])
{
self.vDataSrc = pDataSrc
}
func UpdateDataSrc (_ pStringList:[String])
{
self.vDataSrc += pStringList
}
func GetDataSrc () -> [String]
{
return self.vDataSrc
}
}
PaintUI.swift :
import UIKit
@objc
class PaintUI: NSObject,UITableViewDelegate, UITableViewDataSource {
static let uShared = PaintUI ()
@objc
static func updateUIMessage() {
DispatchQueue.main.async {
ExecuteInlineSelectionTable ()
}
}
func tableView (_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell (withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = "hello"
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let viewcontroller: TWIOSViewController!
viewcontroller = StaticContext.sViewController
}
public static func ExecuteInlineSelectionTable ()
{
let selectiontable:TWOSSelectionTableTVOS!
selectiontable = TWOSSelectionTableTVOS ()
selectiontable.register (UITableViewCell.self, forCellReuseIdentifier: "cell")
selectiontable.dataSource = uShared
selectiontable.delegate = uShared
selectiontable.isScrollEnabled = true
// TODO : will add selection table in view heriearchy but currently getting
// compilation error
}
}
And finally calling PaintUI.updateUIMessage () , it is throughing above errors for tvOS only but in case of ios code is working fine.
when i am adding new view to replace viewcontroller's view like this :
let viewcontroller: UIViewController!
let rootview:UIView!
viewcontroller = UIViewController ()
rootview = UIView (frame:viewcontroller.view.bounds)
viewcontroller.view = rootview
// Adding a button
let button = UIButton(type: .system)
button.setTitle("Tap Me", for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 18)
button.addTarget(self, action: #selector(buttonTapped), for:.allEvents)
viewcontroller.view.addSubview(button)
For ios(iPhone/ipad) , i am able to get button click event .
But in case of tvOS , i am not getting button click event.
But in case of tvOS if use the default view of viewcontroller like this , i am getting button click events and things works fine:
let viewcontroller: UIViewController!
viewcontroller = UIViewController ()
// Adding a button
let button = UIButton(type: .system)
button.setTitle("Tap Me", for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 18)
button.addTarget(self, action: #selector(buttonTapped), for:.allEvents)
viewcontroller.view.addSubview(button)
Is this some bug for tvOS or for tvOS this suppose to happen this way ?
I am experiencing a transition issue like the video
https://drive.google.com/drive/folders/17DheHb6wh8d2ZizTXmTpu7FalTDTJvTY
This issues occur intermittently and, even the system animation(keyboard) is included.
Im using pure swiftUI and The Composable Architecture.
I don’t know the exact cause. I don’t have a great idea for solve this issue.
I am creating an app where i am opening the direct share extension in app for different apps like instagram, snapchat and whatsapp. It is working fine i know there share extension bundle id and it open perfectly. I also need to open the iMessages share extension in app i have found the bundle id of iMessage share extension it is com.apple.UIKit.activity.Message but when i try to open it got error extension not found.
Any one have any idea how i can find the right bundle if for iMessage share extension ?
I am using an iOS SPM package LNExtensionExecutor and create a bridge between React Native and this native package.
I need to instantly and without rotation animation change the screen orientation (and accordingly the size of the frame self.view in the UIViewController). If I do it like this in UIViewController:
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[CATransaction begin];
[CATransaction setDisableActions:YES];
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[self.view setFrame:CGRectMake(0, 0, size.width, size.height)];
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[CATransaction commit];
}];
}
Then, at the moment the screen orientation changes to, I see a flickering of view. How can I do what is necessary?
Hi!
I've got an application that can handle json (export/import).
To achieve that I created a new Document Type in the info.plist, filed the imported and exported Type Identifiers, and created a new UTType.
At first I was trying on the simulator and everything worked fine. I was able to created files and store them in the File app, and then read them back. I also implemented the func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) to handle documents opened from outside the application.
Now when I moved on onto a real device, I noticed that I had to test the access with
guard url.startAccessingSecurityScopedResource() else {
throw ImportError.accessDenied
}
defer { url.stopAccessingSecurityScopedResource() }
but I get a weird behavior : when opening a file from File app with my app launched, everything works fine.
But if I try to launch my application (previously killed) from a file in the File app, startAccessingSecurityScopedResource always returns false
I tried to add the NSFileCoordinator().coordinate(readingItemAt: url, error: &error) { (url) in but I get the same behavior.
I guess my files and UTType are correctly declared as I only see them from inside the `UIDocumentPickerViewController``
and from the File app, I see my application in the share sheet
What am I missing here ?
Thanks
Hello!
When opened viewController is closed, and the caller viewController appears, I iterate through the data that the called viewController modified. And here's the strange part - I can't iterate through the classes in the array, for some reason, even though the conditions for while = true are met - Swift runtime refuses to enter inside while loop.
I've tryed to emulate this situation in playground - there it works just fine. Is it bug in Swift, or some multighreading stuff ? Please help ?
Code is:
https://github.com/afirthes/Numberator
UPDATE: It was some xcode debug caching error, after restart it worked fine.
I have a project that I started on iOS 16 and when iOS 17 came out I was excited about implementing the object capture feature using the reality kit. However, when I check the sample project, the reality kit in it has the object session, object capture view, and object pointcloud classes ready to use, but when I search up these classes and their respective functions on my project, they don't exist. I updated the deployment target to iOS 17.3, yet I still can't use the functions. How do I fix this?
Hi,
I have created a custom UIContentConfiguration + UIContentView for a TableView and using the custom Configuration and the default Configuration from UIListContentConfiguration in a same TableView (Style insetGrouped). But the separators from the custom configuration are different than that from the default configuration. And I didn't see an option to modify this through the custom configuration. Do anybody know how this is done with UIListContentConfiguration? For me currently the only option seems to be using "cell.separatorInset", but for the UIListContentConfiguration I don't need this.
In the image below you see the problem. First, third and fifth cell is default configuration (UIListContentConfiguration.valueCell()). Second and fourth is the custom configuration. And under the custom configuration cells the separator is beginning at zero. This can be fixed with: cell.separatorInset.left = 20.
This one is an example without image, but if I add an image for the default configuration, the text is much more behind and the fix with cell.separatorInset.left = 20 is not working in this case.
For default configuration:
let cell = tableView.dequeueReusableCell(withIdentifier: "default", for: indexPath)
var config = UIListContentConfiguration.valueCell()
config.text = "Test"
config.secondaryText = "Test"
cell.contentConfiguration = config
return cell
For custom configuration:
Configuration + ContentView:
struct SwitchConfiguration: UIContentConfiguration {
var text: String?
var value: Bool
var delegate: SwitchDelegate?
func makeContentView() -> UIView & UIContentView {
return SwitchContentView(configuration: self)
}
func updated(for state: UIConfigurationState) -> SwitchConfiguration {
return self
}
}
class SwitchContentView: UIView, UIContentView {
var configuration: UIContentConfiguration {
didSet {
self.configure()
}
}
private let textLabel: UILabel = UILabel()
private let `switch`: UISwitch = UISwitch()
init(configuration: UIContentConfiguration) {
self.configuration = configuration
super.init(frame: .zero)
self.switch.addTarget(self, action: #selector(self.switchValueDidChange(_:)), for: .valueChanged)
self.addSubview(self.textLabel)
self.addSubview(self.switch)
self.directionalLayoutMargins = .init(top: 8, leading: 20, bottom: 8, trailing: 8)
self.textLabel.translatesAutoresizingMaskIntoConstraints = false
self.textLabel.leadingAnchor.constraint(equalTo: self.layoutMarginsGuide.leadingAnchor).isActive = true
self.textLabel.centerYAnchor.constraint(equalTo: self.layoutMarginsGuide.centerYAnchor).isActive = true
self.switch.translatesAutoresizingMaskIntoConstraints = false
self.switch.trailingAnchor.constraint(equalTo: self.layoutMarginsGuide.trailingAnchor, constant: -16).isActive = true
self.switch.centerYAnchor.constraint(equalTo: self.layoutMarginsGuide.centerYAnchor).isActive = true
self.switch.topAnchor.constraint(equalTo: self.layoutMarginsGuide.topAnchor).isActive = true
self.switch.bottomAnchor.constraint(equalTo: self.layoutMarginsGuide.bottomAnchor).isActive = true
self.configure()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func configure() {
guard let config = self.configuration as? SwitchConfiguration else {
return
}
self.textLabel.text = config.text
self.switch.isOn = config.value
}
@IBAction
func switchValueDidChange(_ switch: UISwitch) {
guard let config = self.configuration as? SwitchConfiguration else {
return
}
config.delegate?.switchValueDidChange(`switch`.isOn)
}
}
Cell:
let cell = tableView.dequeueReusableCell(withIdentifier: "custom", for: indexPath)
var config = SwitchConfiguration()
config.text = "Test"
config.value = true
cell.contentConfiguration = config
//cell.separatorInset.left = 20
return cell