Post

Replies

Boosts

Views

Activity

What's the best way to emulate the Watch Activity Ring Reset?
Hi, I am working on a similar concept to when the Activity Ring resets at midnight, but I was wondering wha tis the best approach to take? Detecting the date change is not the issue. The tricky part that I see is that the device will probably be locked nor can I count on the app being in the background. I was looking at a few options that I do not believe will meet my needs: 1) A Silent Push Notification - The problem is that delivery is not certain by any means according to WWDC sessions / docs. 2) State Change - I can detect date change when user the user opens the app, is there a way to emulate the resetting the rings without the user having to launch the app? 3) Background Refresh - Now this is where I could be wrong, but from what I understand this is based on usage patterns fo the app only. So, I am not certain that I can count on this as well. So, I ask, any suggestions? Thanks.
0
0
626
Dec ’20
Widget works great in the Simulator, but not on the device.
Hello All, I have a Widget that is date based (updates at midnight) that works in the Simulator, but for some reason does not work on an actual device. I checked online and the suggestion that I found was to ensure that the OS version is the same, which they are, but still it's not working. Here's how I am testing on Simulator: 1) Set date time to 11:58. 2) Allow the system clock to roll over to midnight. 3) The widget updates - expected behavior. On Device: 1) Set screen auto lock to never. 2) Charge the phone. 3) Clock rolls to midnight, the Widget does not update. Which also brings me to my second question, is there a way to detect a Widget update when the phone is locked? Thank you
0
0
398
Dec ’20
WidgetKit: Refresh data based on a specific time?
Hi, Is it possible to dynamically update a Widget / show a View based on a specific time? For example, something like the following: func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> ()) { var entries: [SimpleEntry] = [] // Generate a timeline consisting of five entries an hour apart, starting from the current date. let currentDate = Date() // Get specific date / time to update then compare it to system's curren time. var components = DateComponents() components.hour = 12 components.month = 0 let midnight = Calendar.current.date(from: components) if midnight == currentDate { let entry = SimpleEntry(date: Date(), text: "", configuration: ConfigurationIntent()) entries.append(entry) let timeline = Timeline(entries: entries, policy: .atEnd) completion(timeline) } else { for hourOffset in 0 ..< 6 { let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)! let entry = SimpleEntry(date: entryDate, text: update, configuration: ConfigurationIntent()) entries.append(entry) } let timeline = Timeline(entries: entries, policy: .atEnd) completion(timeline) } } } Thanks,
0
0
425
Nov ’20
CollectionView Cell Image: Replace placeholder image with a camera photo.
Hi, I have an UICollecitonView that loads a placeholder image within a ColletionView cell without any problems. The placeholder image is loaded via ‘Assets’ using a string property. class SampleImageView: UIImageView { let placeholderImage = UIImage(named: "Sample") override init(frame: CGRect) { super.init(frame: frame) configure() } '''' func setImage(holder: UIImage) { image = holder } private func configure() { layer.cornerRadius = 10 clipsToBounds = true image = placeholderImage translatesAutoresizingMaskIntoConstraints = false } } In addition, I would like to replace the placeholder image with the one taking via the camera. I know that the image from the camera is loading without any any problems. private func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { picker.dismiss(animated: true) guard let image = info[.editedImage] as? UIImage else { print("No image found") return } imageTaken = true placeHolderImage.contentMode = .center placeHolderImage.image = resizeImage(image: image, targetSize: CGSize(width: 44, height: 44)) } And then from my CollectionView VC: extension SampleCollectionVC: SampleMoveDataDelegate { func didTapAdd(data: SampleData) { // Verify that the VC is getting the image passed to it. let photoSize = data.sampleImage?.size.width print(photoSize)&#9;&#9;// Append data then retake &#9;&#9; if LoadData.shared.getPerscriptionData().isEmpty { LoadData.shared.update(perscription: medicaiton) configureViewController() configureCollectionView() configureDataSource() updateData() DispatchQueue.main.async { self.collectionView.reloadData() } } The collecitonView loads fine, but the placeholder image is displayed and not the camera image. Also fYI, I am applying the datasource snapshot on the main thread. And finally, here's the data struct: struct SampleData: Hashable { var sampleName: String // Perscription name var sampleImage: UIImage? } Does anyone have any recommendations to handle this situation? Thanks,
1
0
984
Aug ’20
Crash, UICollectionView: Snapshot when updating data.
I am able to statically load data and have it display in a CollectionView Diffable / Snapshot view without any problems. But I am getting the following crash ‘Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value’ when attempting to update the data from modal viewController.I am using a shared instance pass data between the viewControllers, and I can use a print statement to see that the data is getting appended. I also tried to update the data on the main queue, but I still got the same error.Here’s the code that I am using, and would appreciate any help.func update(data: [Data]) {var snapshot = NSDiffableDataSourceSnapshot&lt;Section, Data&gt;() snapshot.appendSections([.main]) snapshot.appendItems(data) self.dataSource.apply(snapshot, animatingDifferences: true, completion: nil) }Thanks,
6
0
2.9k
Jun ’20
UISegmentControl with image showing up as black
With iOS 13, I am having where the an UIImage is not being properlty displayed on the screen - I am getting a black blob. I ried setting the tintColor with no luck. I am not using Storyboards and only trying to use images - not text &amp; images. Any suggestions for a workaround / solution?Thank you,Paul
3
0
559
Apr ’20