swift3

MacOS and Swift 3 - how to pass result from one filter to another

强颜欢笑 提交于 2019-12-12 05:09:32
问题 Expanding question from this thread. I'm not sure how to pass the result from CIAffineClamp as a source for CIGaussianBlur . The following code builds just fine but does not yield a resulting image. guard let blurFilter = CIFilter(name: "CIGaussianBlur"), let clampFilter = CIFilter(name: "CIAffineClamp"), let imageURL = Bundle.main.url(forResource: "my-image", withExtension: "png"), let ciImage = CIImage(contentsOf: imageURL) else { return } let transform = AffineTransform.identity

Swift 3 Generics: How to Find The Common Set of Two Generic Arrays

*爱你&永不变心* 提交于 2019-12-12 05:09:01
问题 I am trying to find the common set of two generic arrays in Swift 3. I got a type compatibility error with the code below. This happens on the line where I am trying to add an element to the commons array: "error: cannot invoke 'append' with an argument list of type '(T.Iterator.Element)' commonSet.append(lhsItem)" What is the solution to this problem? func commonElements<T: Sequence, U: Sequence>(_ lhs: T, _ rhs: U) -> [T] where T.Iterator.Element: Equatable, T.Iterator.Element == U.Iterator

Not getting file URL from bundle

邮差的信 提交于 2019-12-12 04:57:44
问题 I am loading PDF file in PDFView but unable to get PDF File URL from Bundle. Please check below code : let pdfView = PDFView(frame: self.view.bounds) let myFileName = "sample" guard let url = Bundle.main.url(forResource: myFileName, withExtension: "pdf") else { return } pdfView.document = PDFDocument(url: url) self.view.addSubview(pdfView) Every time I am getting nil in url . Edit : Here is my Project Window: Am I making any silly mistake ? Please guide me. Thanks in Advance. 回答1: I got

How to show image from the imagePath in swift3

我们两清 提交于 2019-12-12 04:57:33
问题 I have response from soap as image_path (self.posts.value(forKey: "image_path") as! [String])[indexPath.row] This is my response "http://sf.iipl.info/ImageCSharp.aspx?Location=C:\\infinityhost\\demo11.iipl.info\\data\\app\\user_location_photo\\8000034939_Resize\\&FileName=1_35f28e55-ca31-4918-8b41-9eb7f3070ace" i cant convert this response to my url, i want to show this image in my tableViewCell public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) ->

Generating a download link using firebase

跟風遠走 提交于 2019-12-12 04:57:30
问题 I'm creating an application that lets the user upload an image and then display a direct link in a text field. Here is the code that is responsible for uploading the image to my bucket and it is triggered when the user's press the upload button. @IBAction func upload(_ sender: Any) { let imageContained = viewimage.image let storage = Storage.storage() var storageRef = storage.reference() storageRef = storage.reference(forURL: "bucket link") var data = NSData() data = UIImageJPEGRepresentation

print array in struct in alphabetical order and in descending order

我们两清 提交于 2019-12-12 04:53:23
问题 I would like my struct to print its entries in alphabetical order first, then arrange the data in descending order. So the final result would be: "lukes 9", "lukes 4", "smiths 4" struct MyData { var company = String() var score: Int } let data = [ MyData(company: "smiths", score: 4 ), MyData(company: "lukes", score: 4), MyData(company: "lukes", score: 9) ] 回答1: There's 2 ways you can do this. Both would require you to pass your array to sort (Swift 2), now sorted (Swift 3). A very easy

Weird issue while using IBDesignable UILabel class

杀马特。学长 韩版系。学妹 提交于 2019-12-12 04:47:46
问题 I am facing a weird issue when I try to use the custom UILabel that I have designed. The view is visible in the storyboard and its working fine with properties. Now What I have done is in my Designable class i have set a property called isError which when set, I need to append an * at the start of my text. But as soon as in my code I do that, My Designable properties are not used and the Label is not correctly shown on the device and it takes the default properties of UILabel without adding *

Implement peek and pop to multiple UITableView in one UIViewController

匆匆过客 提交于 2019-12-12 04:43:30
问题 I have two UITableView in one ViewController and a UIView , and I'm trying to implement Peek and Pop but every time I register both the tables, it only works for the first table. Following is where I'm registering the UITableViews : if traitCollection.forceTouchCapability == UIForceTouchCapability.available { registerForPreviewing(with: self, sourceView: self.tableView2) registerForPreviewing(with: self, sourceView: self.tableView) } My viewControllerForLocation : if tableView.point(inside:

Swift 3 - NSString.draw(in: rect, withAttributes:) — Text not being drawn at expected point

佐手、 提交于 2019-12-12 04:40:06
问题 Teeing off of this Stackoverflow post, which was very helpful, I've been able to successfully draw text onto a full-screen image (I'm tagging the image with pre-canned, short strings, e.g., "Trash"). However, the text isn't appearing where I want, which is centered at the exact point the user has tapped. Here's my code, based on some code from the above post but updated for Swift3 -- func addTextToImage(text: NSString, inImage: UIImage, atPoint:CGPoint) -> UIImage{ // Setup the font specific

Swift 3 iOS - Synchronised Pause with AVAudioPlayer

爱⌒轻易说出口 提交于 2019-12-12 04:37:33
问题 I am using AVAudioPlayer to play a set of synchronised MP3 files in a player style interface (Play/Pause/Stop). I am aware that I can synchronise playing them by using play(atTime:) but my question is, how do I synchronise pausing them? At the moment, to pause them, I am using: for (_, audioTrackPlayer) in audioTrackPlayers.enumerated() { audioTrackPlayer.pause() } But of course, they all pause one after the other. There is no equivalent pause(atTime:) function. So how can precise