swift3

If a filter is applied to a PNG where height > width, it rotates the image 90 degrees. How can I efficiently prevent this?

倾然丶 夕夏残阳落幕 提交于 2019-12-13 18:12:50
问题 I'm making a simple filter app. I've found that if you load an image from the camera roll that is a PNG (PNGs have no orientation data flag) and the height is greater than the width, upon applying certain distortion filters to said image it will rotate and present it self as if it were a landscape image. I found the below technique online somewhere in the many tabs i had open and it seems to do exactly what i want. It uses the original scale and orientation of the image when it was first

Xcode 8 - Command failed due to signal: Illegal instruction: 4

让人想犯罪 __ 提交于 2019-12-13 18:09:05
问题 I just migrated my project to Swift 3.0 using Xcode 8 . The app is working fine on a device and in the simulator. However, when I archive it in preparation to upload to app store I get stuck with the error: Command failed due to signal: Illegal instruction: 4 I have cleaned the build and removed the derived data folder. CocoaPods installations are up-to-date. I tried commenting out all code related to dictionaries that was the solution to this similar Xcode 7 issue, but I still get the error.

Swift 3 Colour Space macOS not IOS

喜欢而已 提交于 2019-12-13 17:31:26
问题 How can I convert an RGB image into its grayscaled colour space? I can find a lot of code for iOS but non for macOS.. And the Apple's documentations are all in objective C.... let width = image.size.width let height = image.size.height let imageRect = NSMakeRect(0, 0, width, height); let colorSpace = CGColorSpaceCreateDeviceGray(); let bits = image.representations.first as! NSBitmapImageRep; bitmap!.representationUsingType(NSBitmapImageFileType.NSPNGFileType, properties: nil) let bitmapInfo =

Swift 3: Cant programmatically create label on Collectionview header properly?

Deadly 提交于 2019-12-13 17:19:48
问题 Alright, so Im working in Swift 3 here and Im new to uicollectionviews. I am trying to programmatically add a label as a subview of a header UICollectionReusableView in my collection view. I have added the label like any other view, but I cant for the life of me CENTER the label on the header. Here is my label code in the custom header class, which is added to the header in the storyboard: let pointsLabel = UILabel() override init(frame: CGRect) { super.init(frame: frame) self.customInit() }

Binary operator '*' cannot be applied to operands of type 'Float' and 'Float!'

浪尽此生 提交于 2019-12-13 16:22:31
问题 When I do the following: let gapDuration = Float(self.MONTHS) * Float(self.duration) * self.gapMonthly; I get the error: Binary operator '*' cannot be applied to operands of type 'Float' and 'Float!' But when I do: let gapDuration = 12 * Float(self.duration) * self.gapMonthly; Everything is working fine. I have no Idea what this error is telling me. self.gapMonthly is of type Float! and self.duration and self.MONTHS are of type Int! 回答1: I would consider this a bug (at the very least, the

how to Display Files From Files Sharing in Swift 3

荒凉一梦 提交于 2019-12-13 15:47:51
问题 A added File Sharing in Plist in My app So I can Easily Copy Files when The iPhone has connect with iTunes to my mac But the problem is that when I copy some files with iTunes in my App and Run the app I have 2 Problems : 1- when I stop the app and open that again I can't see any files in iTunes in the file sharing part 2- This code Below here should print file Exists if there is file and print some thing else if there isn't file But Just Print File Exists here is my codes if filemgr

Naming convention for Private Properties

北战南征 提交于 2019-12-13 15:23:20
问题 I've seen underscore used as a prefix for private properties private var _aPrivateVar: String = "I am private" I've seen them not used private var aPrivateVar: String = "I am private" Syntactically, it makes no difference and my preference is to not use them. However, what's the accepted convention in Swift so that I pick the right habit up? 回答1: In this Swift Guide style, you can find a similar reference: private var centerString: String { return "(\(x),\(y))" } In The swift Programming

how to use custom cell in collection view controller in swift 3

不羁的心 提交于 2019-12-13 14:15:28
问题 I am using swift 3 - I know how to show some Images in collection view with custom Cell - the problem is that I can't use custom cell in Collection View Controller here is the collection view Controller Codes private let reuseIdentifier = "uploadCell" class uploadedFiles: UICollectionViewController { var images = ["1.jpg" , "2.jpg" , "3.jpg" , "4.jpg" ] override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell =

Avoid creation of multiple ViewController instances, iOS Swift

此生再无相见时 提交于 2019-12-13 14:02:58
问题 In AppDelegate, the below function gets called whenever VoIP call (push notification) is received thereby creating multiple instances of "VideoCallViewController" I've used deinit (in VideoCallViewController) as shown below, to check if the previous instance of "VideoCallViewController" was being de-initialised before a new instance of "VideoCallViewController" is created, to my surprise print("Deinitializing VC) wasn't called, leaving the instance in memory. How can I show

DispatchQueue.main.sync returning exc_bad_instruction Swift 3

℡╲_俬逩灬. 提交于 2019-12-13 12:53:38
问题 I want to display an ActivityIndicatorView in my app, but when I call the sync method from the main thread, the app crashes with the error: exc_bad_instruction (code=exc_i386_invop subcode=0x0) I'm using xcode 8.0 and swift 3 Can someone please help me? func POST(endpoint:NSString!,body:NSString!,vc:UIViewController? = nil)->NetworkResult{ let result = NetworkResult() DispatchQueue.main.sync { self.displayActivityIndicator(viewController: vc) } let urlStr = self.url.appending(endpoint as