Posts

Post marked as unsolved
1.5k Views

"Unable to simultaneously satisfy constraints"

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 ****** 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.
Asked
by fpiraneo.
Last updated .
Post marked as unsolved
369 Views

Access HEIC and DNG pictures from iOS 11 camera roll

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.
Asked
by fpiraneo.
Last updated .
Post marked as unsolved
552 Views

Reading URLResourceKey.customIconKey and URLResourceKey.thumbnailKey file attributes

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.
Asked
by fpiraneo.
Last updated .
Post marked as unsolved
232 Views

UIImageView: How to show scaled image?

Hi all,I'm new to iOS app development and I begun to learn from this great tutorial:Start Developing iOS Apps (Swift)https://developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/WorkWithViewControllers.html#//apple_ref/doc/uid/TP40015214-CH6-SW1Everything looks great but when trying to load an image from "Camera roll" on the simulator, I get the image shown oversized and filling all the iPhone simulator screen instead of just showing into the UIImageView box as shown on tutorial images.The funny fact is that also downloading the correct project provided at the end of the lesson (see the bottom of the page) I get the same issue.Googling around I get some ideas to insert a:photoImageView.contentMode = UIViewContentMode.scaleAspectFitafter loading image from the camera roll, but lead to no results...I'm using Xcode 9.2 with deployment target 11.2 and iPhone 8 plus as a target for the simulator.Any help is apreciated.Francesco
Asked
by fpiraneo.
Last updated .