Posts

Post marked as solved
1 Replies
73 Views
Hello! I'm working with the UIHostingConfiguration and would like to set a Toolbar for a TextField which I placed in the content. I've tried to set ToolbarRole and Toolbar Visibility. Unfortunately, it doesn't work. Here's my example code: Cell: cell.configurationUpdateHandler = { (cell, state) in     cell.contentConfiguration = UIHostingConfiguration {          RowView(item: item)      } } View:     @ObservedObject var item: Movie     var body: some View {         TextField("Title", text: $item.title)             .toolbar(content: {                 ToolbarItem(placement: .keyboard) {                     Button("Confirm", action: {})                 }             })             .toolbar(.visible, in: .automatic)     } }
Posted Last updated
.
Post not yet marked as solved
1 Replies
176 Views
Hi! I'm experimenting with UIHostingConfiguration. I put a textfield in the cell's coniguration and would like to observe its state. I created a @FocusState variable and set the focused(_:). But I've noticed that @FocusState doesn't work in UIHostingConfiguration. Here' my code: struct TaskView: View {          @ObservedObject var task: Task     @FocusState private var isFocused: Bool     var body: some View {         HStack(spacing: 10) {             Image(systemName: (task.isCompleted == true) ? "checkmark.square.fill" : "square")                 .font(Font.system(size: 20, weight: .medium))                 .foregroundColor(.gray)                 .onTapGesture {                     task.isCompleted = true                 }             VStack(alignment: .leading, spacing: 3) {                 TextField("Task", text: $task.name)                     .onSubmit {                         try! (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext.save()                     }                     .focused($isFocused)                     .submitLabel(.done)                     .onChange(of: isFocused) { newValue in                         print(newValue) //always returns false                     }                 HStack(spacing: 2) {                     Image(systemName: "moon.fill")                         .resizable()                         .frame(width: 10, height: 10)                         .foregroundColor(.blue)                     Text("Tomorrow")                         .font(.footnote).bold()                         .foregroundColor(.gray)                 }             }         }     } }
Posted Last updated
.
Post not yet marked as solved
0 Replies
144 Views
Currently, I work with CKSubcription and remote notifications. I have a question concerns application(_:didReceiveRemoteNotification:fetchCompletionHandler:) method. In Apple's documentations we can read: As soon as you finish processing the notification, you must call the block in the handler parameter or your app will be terminated. Your app has up to 30 seconds of wall-clock time to process the notification and call the specified completion handler block. In practice, you should call the handler block as soon as you are done processing the notification. Source: https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623013-application The method works correctly. My app "wakes up" when got a notification (to observe that, I use option + command + escape). Do I correctly undrestand? - when I call hadler block, should app close immediately? My app closes after 30 second, even if I put only completionHandler(...) in this method. I asked beacuse in the documentation we can read. Your app has UP to 30 seconds Thank you in advance.
Posted Last updated
.
Post not yet marked as solved
0 Replies
189 Views
I work with Core Data and I needed to change CloudKit container in Singing & Capabilities. I've done it successed, I think. But when I run my app, NSCloudKitMirroringDelegate returns the error with user info: NSLocalizedFailureReason=Subscription save succeeded but did not return 'com.apple.coredata.cloudkit.shared.subscription' as a saved subscription I've registred my app's ID and I've checked iCloud. Thanks in advanced.
Posted Last updated
.
Post not yet marked as solved
0 Replies
330 Views
I'm trying to use NSFetchedResultsController with UICollectionView List. It works good, but when NSFetchedResultsController detect changes I get error: Could not cast value of type '_NSCoreDataTaggedObjectID' (0x7fff8091b280) to 'ProjectName.Person' (0x1053479e0). It's my code:     func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeContentWith snapshot: NSDiffableDataSourceSnapshotReference) {                  if dataSource==nil {             return         }                  guard let dataSource = collectionView?.dataSource as? UICollectionViewDiffableDataSource<Int, Person> else {             return         }         var snapshot = snapshot as NSDiffableDataSourceSnapshot<Int, Person>         let currentSnapshot = dataSource.snapshot() as NSDiffableDataSourceSnapshot<Int, Person>         let reloadIdentifiers: [Person] = snapshot.itemIdentifiers.compactMap { itemIdentifier in             guard let currentIndex = currentSnapshot.indexOfItem(itemIdentifier), let index = snapshot.indexOfItem(itemIdentifier), index == currentIndex else {                 return nil             }             guard let existingObject = try? controller.managedObjectContext.existingObject(with: itemIdentifier.objectID), existingObject.isUpdated else { return nil }             return itemIdentifier         }         snapshot.reloadItems(reloadIdentifiers)         let shouldAnimate = collectionView?.numberOfSections != 0         dataSource.apply(snapshot as NSDiffableDataSourceSnapshot<Int, Person>, animatingDifferences: shouldAnimate)     } Please help
Posted Last updated
.
Post not yet marked as solved
0 Replies
238 Views
I’d like to write expanding rows in UITableView, which display content from NSFetchedResultsController. It’s struct of object: • Object • array of sub-objects I can’t insert new rows with expanded sub-objects. Please help.
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.1k Views
Hi! I have question. How can I insert image to text view with smaller size(scaled to text view), but with keeping quality? Like in Notes on iOS - picture with high quality weight around 800kB. Thanks.
Posted Last updated
.
Post not yet marked as solved
4 Replies
1.1k Views
I have issue. I'd like to place attachment (like on attached picture; it's Notes on iOS) in UITextView. I tried use NSTextAttachment, but on iOS I couldn't use NSTextAttachmentCell. I'd like to attachment will be part of text. I've tried use exclusion paths, but custom view wasn't be a part of text. Thank you.
Posted Last updated
.