swift3

Adding buttons to navigation controllers

有些话、适合烂在心里 提交于 2019-12-26 06:04:27
问题 I am working in a swift 3 xcode 8 project, and I have an issue. I have some view controllers. In the first one I've inserted a navigation controller, which gives me the "back" button when I am in another view controller. So I can go on and back to the first viewcontroller. The thing is, lets say, when I am in the third view controller I'd like to insert a button, but appearing just in this viewcontroller in the navigation controller. I've tried adding a bar button item but it doesnt work

Facebook SDK error for subscript members [duplicate]

南楼画角 提交于 2019-12-25 19:04:49
问题 This question already has answers here : Type 'Any?' has no subscript members [duplicate] (2 answers) Closed 3 years ago . I am using Facebook SDK for login and fetching data at my end but unable to solve the issue I am facing challenges related to syntax func fetchProfile() { let parameters = ["fields": "email, first_name, last_name, picture.type(large)"] FBSDKGraphRequest(graphPath: "me", parameters: parameters).start(completionHandler: { (connection, user, requestError) -> Void in if

Nothing Occurring with ScrollToItem in UICollectionView

无人久伴 提交于 2019-12-25 18:29:13
问题 I have two collection views within a ViewController. One Collection view represents the tab bar at the top, the other represents pages on the bottom half of the screen. I have the second UICollectionView (on the bottom half) within a custom UIView (loading from another class). My objective is to have when I click on the tab bar, to move the bottom collectionView accordingly, with regards to the scrollToIndex. My issue is that when I click on the tab bar at the top, and call the function that

swift 3 CGPathAddCurveToPoint

坚强是说给别人听的谎言 提交于 2019-12-25 18:21:55
问题 I'm trying to update code to swift 3 but I can't find anything about CGPathAddCurveToPoint, how can I fix the error? path is a CGMutablePath CGPathAddCurveToPoint(path, nil, 10, 10, 20, 20, 30, 30) error: nil is not compatible with expected argument type 'UnsafePoiter' I found that CGPathAddLineToPoint(path, nil, 10, 10) became path.addLine(to: p0) 回答1: Please read the CGMutablePath docs: https://developer.apple.com/reference/coregraphics/cgmutablepath You will find: func addCurve(to end:

Swift is giving non-void return error even though it is set to Double?

情到浓时终转凉″ 提交于 2019-12-25 18:19:25
问题 I am getting this error: /Users/xxxx/Desktop/xxx/xxx/ViewController.swift:43:38: Unexpected non-void return value in void function And others like this even though my functions are set to return Double. This is one of the functions of which this error is appearing in every return. func readWeight() -> Double { let quantityType = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.bodyMass) let weightQuery = HKSampleQuery(sampleType: quantityType!, predicate: nil, limit: 1,

How to change the action of NSColorWell?

情到浓时终转凉″ 提交于 2019-12-25 18:02:21
问题 I can use NSColorWell as button to change the color of selected text. Since NSColorWell is object of an NSControl it has target and action. I guess, the action is implementing the code to change the color of the selected text in NSTextView. Where can I find this code for NSColorWell action? I would like to change it in away that I can use NSColorWell to change the background of the selected text, and ultimately to have in ToolBar two NSColorWell buttons: one to change text's foreground color

Count number of mutual friends in Firebase

送分小仙女□ 提交于 2019-12-25 17:45:06
问题 I'm trying to pull the number of mutual friends that I have with any given userID. I first pulled all my friends from Firebase and then I pulled the userID's friends. I'm just not sure how to count the number of mutual friends from there. Please let me know if I'm going about it the wrong way. func fetchMutualFriends(myID: String, userID: String) { let myID = Auth.auth().currentUser!.uid let postRef = self.databaseRef.child("friends").child(myID) postRef.observe(.value, with: { (snapshot) in

Swift3 AudioToolbox: PCM playback how to AudioQueueAllocateBuffer?

隐身守侯 提交于 2019-12-25 16:57:48
问题 I am following https://github.com/AlesTsurko/LearningCoreAudioWithSwift2.0/tree/master/CH05_Player to playback a frequency but it is with Swift2. Get microphone input using Audio Queue in Swift 3 has resolved many of the issues but it is for recording. I am stuck at allocating a buffer to audio queue var ringBuffers = [AudioQueueBufferRef](repeating:nil, count:3) AudioQueueAllocateBuffer(inQueue!, bufferSize, &ringBuffers[0]) It gives an error main.swift:152:29: Expression type '

Adjust the size of UITableView dynamically which would display as a non-scrollable list of content

佐手、 提交于 2019-12-25 16:55:36
问题 I'm working on a project in Swift 3.0 and it has a UITableView inside a UIScrollView that has already been set its constraints. The requirement is to display a list of songs that would return from an array in this UITableView, but the size of this UITableView should dynamically arrange according to the size of the array, so I do not need to scroll the UITableView since I can see all the songs in the UITableView (this UITableView is inside my scrollView, so instead I can use my scrollView do

Adjust the size of UITableView dynamically which would display as a non-scrollable list of content

旧城冷巷雨未停 提交于 2019-12-25 16:55:20
问题 I'm working on a project in Swift 3.0 and it has a UITableView inside a UIScrollView that has already been set its constraints. The requirement is to display a list of songs that would return from an array in this UITableView, but the size of this UITableView should dynamically arrange according to the size of the array, so I do not need to scroll the UITableView since I can see all the songs in the UITableView (this UITableView is inside my scrollView, so instead I can use my scrollView do