swift3

How to change separator height in UITableView Swift 3?

随声附和 提交于 2019-12-19 04:50:52
问题 Although there a few answers already on this topic. None of them cover Swift 3 and they are from a long time ago. What is currently the best way to change the separator height in a UITableView in Swift 3? 回答1: Updated for Swift 3: If you want to change the height of the UITableView separator, use the code below. You should add it to the UITableViewCell method awakeFromNib() to avoid re-creation. override func awakeFromNib() { super.awakeFromNib() // Initialization code let mScreenSize =

swift: didSelectRowAtIndexPath

雨燕双飞 提交于 2019-12-19 04:46:12
问题 I have tableViewController. I want to click on 1 cell and get print("0") and click on 2 cell and get print("1") But my code doesn’t work. Why? import UIKit class MasterViewController: UITableViewController { override func viewDidLoad() { super.viewDidLoad() tableView.delegate = self tableView.dataSource = self } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } // MARK: - Table view data source override func numberOfSections(in tableView: UITableView) -> Int { return

How do you make a shake animation for a button using Swift 3 [closed]

本秂侑毒 提交于 2019-12-19 03:39:10
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I have a function that gets called every 3 seconds. How can I make a shaking animation for the button that shakes side to side. func shakeButton() { if opened == false { //Shake Animation } } 回答1: if I understood you correctly, try this on shake animation. Simply use this method

Charts lineChartDataset rounded values

て烟熏妆下的殇ゞ 提交于 2019-12-19 03:37:13
问题 I'm trying out a few things with the iOS Charts library with Swift 3.0. I have a question about formatting of the lineChartDataset values (displayed above each value point). Right now these values are 'double' and are displayed as 2.0 and 3.0 instead of just 2 and 3 etc. Is it possible to round these values? I tried with numberFormatter but nothing works. Any help would be appreciated. 回答1: ios-charts have been upgraded to protocol base approach for rendering the various kind of labels like

UIImagePickerController leaking memory after launch and during taking a picture. Makes app crash after taking more than a 100 pictures

不打扰是莪最后的温柔 提交于 2019-12-19 03:13:28
问题 I have been struggling with this issue for weeks now. I have look online all over the place and found nothing close to this issue other than this 2 outsider links: https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview/issues/200 https://issues.apache.org/jira/browse/CB-11784 But those are not using the same environment and there is no actual solution to the problem. Here is a screenshot of my Instrumentals using Xcode 8.3 right after I launch the imagePicker and take

Best practice for storing temporary data in swift

久未见 提交于 2019-12-19 03:07:20
问题 I have developed an app that gets a lot of JSON data from server and shows on different VCs.What I did was getting data and setting data to static variables , so I can access data in all my app. Now I noticed that I could have used CoreData or maybe UserDefaults instead of Static variables . My question is "What is the best practice for this type of apps and why exactly ?" NOTE : The app doesn't need to work offline and save data for showing in offline mode. 回答1: You should not store data to

Error: value of type 'String' has no member 'hasSuffix' in Swift switch

醉酒当歌 提交于 2019-12-19 02:54:34
问题 I'm following tutorials from Swift.org The below example of switch statement throws an error. let vegetable = "red pepper" switch vegetable { case "celery": print("Add some raisins and make ants on a log.") case "cucumber", "watercress": print("That would make a good tea sandwich.") case let x where x.hasSuffix("pepper"): print("Is it a spicy \(x)?") default: print("Everything tastes good in soup.") } The error am getting is : error: value of type 'String' has no member 'hasSuffix' case let x

Delete last character in Swift 3

大兔子大兔子 提交于 2019-12-19 02:46:11
问题 I'm creating a simple calculator app and currently struggling at deleting the last character when a my button is tapped. I'm using the dropLast() method but I keep getting the error Missing Argument for parameter #1 in call @IBAction func onDelPressed (button: UIButton!) { runningNumber = runningNumber.characters.dropLast() currentLbl.text = runningNumber } 回答1: Swift 4 (Addendum) In Swift, you can apply dropLast() directectly on the String instance, no longer invoking .characters to access a

What is an example of drawing custom nodes with vertices in swift SceneKit?

喜你入骨 提交于 2019-12-19 02:08:22
问题 This area is hardly documented online and it would be great to see a working Swift 3 example, of say, a custom drawn cube with manual SCNvector3s. There is this in objective-C but not Swift. This might not be a usual form of question but I know it would help many. If there is somewhere I missed, please mention. The documentation is not very helpful scngeometrysource, etc. Thanks 回答1: A custom geometry is constructed from a set of vertices and normals. Vertices In this context, a vertex is a

EXC_BAD_ACCESS code=2 on including Firebase/Auth in Podfile

随声附和 提交于 2019-12-18 21:50:49
问题 I am getting EXC_BAD_ACCESS after including 'Firebase/Auth' in Podfile. This happens without adding any line of firebase code. I am using swift3 on xcode 8 and the resultant pods are - Installing Firebase (3.8.0) Installing FirebaseAnalytics (3.5.1) Installing FirebaseAuth (3.0.6) Installing FirebaseCore (3.4.4) Installing FirebaseInstanceID (1.0.8) Using GTMOAuth2 (1.1.4) Using GTMSessionFetcher (1.1.7) Using GoogleAppUtilities (1.1.2) Installing GoogleInterchangeUtilities (1.2.2) Using