swift2

Draggable label - ios

爷,独闯天下 提交于 2020-01-10 05:30:14
问题 I have a requirement to move a label around only when the user touches on it and drags. I cant find out whether the user touched that label or not. I have used the touchesMoved method(Swift 2). Below is my code override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) { super.touchesBegan(touches as Set<UITouch>, withEvent: event) let touch = touches.first if (touch!.view) == (moveLabel as UIView) // moveButton is my label { location = touch!.locationInView(self.view)

Cannot invoke initializer for type 'NSURL' with an argument list of type '(fileURLWithPath: NSURL)'

空扰寡人 提交于 2020-01-07 06:57:57
问题 I upgraded my code for Swift 2, here I got an error: Cannot invoke initializer for type NSURL with an argument list of type (fileURLWithPath: NSURL) Here's the code: let dirPaths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true) let docsDir = dirPaths[0] let soundFilePath = NSURL(fileURLWithPath: docsDir).URLByAppendingPathComponent("sound.caf") let soundFileURL = NSURL(fileURLWithPath: soundFilePath) //The error goes

Custom figure doesn't display in Today Extension

南楼画角 提交于 2020-01-07 03:54:36
问题 I make progress circle in today extension. I create additional class for it. I can see it in storyboard with help of IBDesignable . But circle doesn't appear in today extension on real device ( iPhone 5s, iPad 3) or simulator. How can I fix it? import UIKit @IBDesignable class CPUView: UIView { // MARK: - colors @IBInspectable var firstColor: UIColor = UIColor.blackColor() @IBInspectable var secondColor: UIColor = UIColor.greenColor() @IBInspectable var thirdColor: UIColor = UIColor

Using a variable as a key for a PFQuery to filter out users. Swift Querying a User

╄→尐↘猪︶ㄣ 提交于 2020-01-07 03:10:08
问题 Variable in a User class as a string. Using this variable as a key for a PFQuery and use it to filter out the users that don't have it.I need to skip users that don't have it and add the users that do to the VC display. Here is my code so far: In the VC where the variable is stored I have: var genreSearch: NSString? after viewDidLoad in a cell I have: let genreSearch = table_data[indexPath.row] userDefaults.setObject(genreSearch, forKey: "genre") print(genreSearch)` Then on the VC where the

IOS Swift beginner [closed]

雨燕双飞 提交于 2020-01-07 02:58:05
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 years ago . In a screen, view-scrollview-contentview, there are a lot of textfields in the contentview so I use a scrollview to make them in one screen.Now the problem is I could not click or type in the textfield because I know the scrollview has covered the contentview. But I want to type in the textfield

Multi select is not working properly in IOS

旧时模样 提交于 2020-01-07 00:52:08
问题 I have a problem with setting the checkmark for a row in iOS table view If I select one element above, the next 13th element is also getting selected, I not sure why? Should I have to do something with the table before setting the checkmark, cause I am just checking one condition and if that condition is true I am setting the accessoryType as checkmark, below is the code. Note:- When this happen the 13th row will not get selected, it just changes the accessory type of that row. if let cell =

How to create a grouped TableView without using a TableViewController

走远了吗. 提交于 2020-01-06 23:52:07
问题 I have a UITableView and I would like it to have 2 sections. I now know that you can only have grouped sections if you're using a UITableViewController and if you're using static cells, neither of which I am. Is that I want to do possible? If so where can I turn for help on setting this up. It seems like every tutorial I have found is for the example of using a UITableViewController. 回答1: Setting the tableView's style property to .Grouped and return 2 from numberOfSections... -method should

Authenticated http request swift Alamofire

走远了吗. 提交于 2020-01-06 19:43:09
问题 I'm struggling with getting this to work to make request to my API. Without a token works, but when I try to add additional headers, things turn to be complicated, for me. First, the structure. one class called: APIAsyncTask that makes the requests one class called APIParams , just a data holder to send parameters to the APIAsyncTask class. one class called DatabaseAPI that makes that builds the parameters, and send that to the APIAsyncTask class. DatabaseAPI func someMethod() { let task =

Make explosion animation SKaction and remove

最后都变了- 提交于 2020-01-06 18:41:21
问题 I want to make a animation to my game when two sprite nodes have a collision. So i create this function : func contactEntreMeteorites(Meteorites : SKSpriteNode , Meteorites2 : SKSpriteNode){ Meteorites.removeFromParent() Meteorites2.removeFromParent() let ExplosionTexture1 = SKTexture(imageNamed: "Explosion1.png") let ExplosionTexture2 = SKTexture(imageNamed: "Explosion2.png") let ExplosionTexture3 = SKTexture(imageNamed: "Explosion3.png") let ExplosionTexture4 = SKTexture(imageNamed:

Make explosion animation SKaction and remove

我的未来我决定 提交于 2020-01-06 18:41:11
问题 I want to make a animation to my game when two sprite nodes have a collision. So i create this function : func contactEntreMeteorites(Meteorites : SKSpriteNode , Meteorites2 : SKSpriteNode){ Meteorites.removeFromParent() Meteorites2.removeFromParent() let ExplosionTexture1 = SKTexture(imageNamed: "Explosion1.png") let ExplosionTexture2 = SKTexture(imageNamed: "Explosion2.png") let ExplosionTexture3 = SKTexture(imageNamed: "Explosion3.png") let ExplosionTexture4 = SKTexture(imageNamed: