Posts

Post not yet marked as solved
2 Replies
3.8k Views
Hi all,always running into the FoodTracker tutorial; following this step: "Implement a custom control"https://developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/ImplementingACustomControl.html#//apple_ref/doc/uid/TP40015214-CH19-SW1and when executing the first checkpoint the simulator shows a red rectangle instead of a square as indicated on the tutorial; on the debug pane I get:2018-02-09 11:19:42.130595+0100 FoodTracker[7439:80369] [MC] Lazy loading NSBundle MobileCoreServices.framework 2018-02-09 11:19:42.131628+0100 FoodTracker[7439:80369] [MC] Loaded MobileCoreServices.framework 2018-02-09 11:19:42.165143+0100 FoodTracker[7439:80369] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "<NSLayoutConstraint:0x60400028a3c0 UIButton:0x7f8a0bd0e330.width == 44 (active)>", "<NSLayoutConstraint:0x60400028cda0 'UISV-canvas-connection' FoodTracker.RatingControl:0x7f8a0bd08890.leading == UIButton:0x7f8a0bd0e330.leading (active)>", "<NSLayoutConstraint:0x60400028ce40 'UISV-canvas-connection' H:[UIButton:0x7f8a0bd0e330]-(0)-| (active, names: '|':FoodTracker.RatingControl:0x7f8a0bd08890 )>", "<NSLayoutConstraint:0x60400028c940 'UIView-Encapsulated-Layout-Width' FoodTracker.RatingControl:0x7f8a0bd08890.width == 200 (active)>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x60400028a3c0 UIButton:0x7f8a0bd0e330.width == 44 (active)> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful. 2018-02-09 11:19:42.165949+0100 FoodTracker[7439:80369] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "<NSLayoutConstraint:0x60400028a370 UIButton:0x7f8a0bd0e330.height == 44 (active)>", "<NSLayoutConstraint:0x60400028a320 'UISV-canvas-connection' FoodTracker.RatingControl:0x7f8a0bd08890.top == UIButton:0x7f8a0bd0e330.top (active)>", "<NSLayoutConstraint:0x60400028cf30 'UISV-canvas-connection' V:[UIButton:0x7f8a0bd0e330]-(0)-| (active, names: '|':FoodTracker.RatingControl:0x7f8a0bd08890 )>", "<NSLayoutConstraint:0x60400028c990 'UIView-Encapsulated-Layout-Height' FoodTracker.RatingControl:0x7f8a0bd08890.height == 110 (active)>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x60400028a370 UIButton:0x7f8a0bd0e330.height == 44 (active)> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.I think that something is changed when programmatically create the button and applying custom constraints here: (I'm working with Swift and Xcode 9)// Add constraints button.translatesAutoresizingMaskIntoConstraints = false button.heightAnchor.constraint(equalToConstant: 44.0).isActive = true button.widthAnchor.constraint(equalToConstant: 44.0).isActive = trueAny hint to solve the issue is welcome.PS: Really gentleman, I don't like as a newbye to bother you with my stupid questions but, I suppose, that Apple should updates their tutorial to provide the best learning experience possible to their developers... I think this is a classical compatibility issue from older to newest libraries and docs not updated.
Posted
by fpiraneo.
Last updated
.
Post not yet marked as solved
0 Replies
1.1k Views
I'm in throubles accessing original HEIC and DNG files from my iOS 11 app, written in Swift; following the Apple developer's documentation, to access original files it's enought to set imagePicker.imageExportPreset = UIImagePickerController.ImageURLExportPreset.current but on the UIImagePickerController.InfoKey.imageURL I still get an URL pointing to a JPEG file; I know the choosen pictures are HEIC and DNG because exporting as original on Mac photo app I get the original file format.This is the complete code I use:@IBAction func openRoll(_ sender: Any) { if UIImagePickerController.isSourceTypeAvailable(.photoLibrary) { let imagePicker = UIImagePickerController() imagePicker.delegate = self imagePicker.sourceType = .photoLibrary imagePicker.allowsEditing = false imagePicker.imageExportPreset = .current self.present(imagePicker, animated: true, completion: nil) } }And on delegate:func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { let image = info[UIImagePickerController.InfoKey.originalImage] as! UIImage let path = info[UIImagePickerController.InfoKey.imageURL] as! NSURL NSLog("URL: \(path.absoluteString)") NSLog("Export: \(picker.imageExportPreset.rawValue)") dismiss(animated:true, completion: nil) // ...code to use the image! }Thank you very much for help, suggestions and working snippets.
Posted
by fpiraneo.
Last updated
.
Post not yet marked as solved
2 Replies
818 Views
I'm trying to read the URLResourceKey.customIconKey and URLResourceKey.thumbnailKey file attributes with a Swift 4 app; as you guess I have some issue because no NSImage will be returned.Questions: Does the two above keys refers to the custom icon (i.e. the Adobe Acrobat documents icon) and the thumbnails of the png / jpeg files?If it's not the case, what the two keys really refers to?Apple documentation has a really short description and google gave no results about.By the way, here is the code I'm working on. // Get file informations let requiredAttributes : Set = [URLResourceKey.nameKey, URLResourceKey.creationDateKey, URLResourceKey.contentModificationDateKey, URLResourceKey.fileSizeKey, URLResourceKey.isPackageKey, URLResourceKey.thumbnailKey, URLResourceKey.customIconKey] do { let properties = try localURL.resourceValues(forKeys: requiredAttributes) metadata.name = properties[URLResourceKey.nameKey] as? String ?? "" let customIcon = properties[URLResourceKey.customIconKey] as? NSImage ?? nil if customIcon != nil {let saveURL = URL(fileURLWithPath: "/Users/fpiraneo/Desktop/fileicon.png")try customIcon!.savePNGRepresentationToURL(url: saveURL)}let customThumbnail = properties[URLResourceKey.thumbnailKey] as? NSImage ?? nilif customThumbnail != nil {let saveURL = URL(fileURLWithPath: "/Users/fpiraneo/Desktop/filethumbnail.png")try customThumbnail!.savePNGRepresentationToURL(url: saveURL)} } catch { let errorDescription = "Error reading file attributes: \(localURL.absoluteString)" comLog.addError(errorDescription) return }Thank you for your help.
Posted
by fpiraneo.
Last updated
.