swift3

custom titleView of navigationItem is not getting tapped on iOS 11

亡梦爱人 提交于 2020-01-24 13:02:08
问题 I am using a custom titleView and assigning it to navigationItem titleView. It had been working fine until iOS 11. Since the update it's position got misplaced to center as originally it was on more left. Beside that user interaction is not working. titleView = Bundle.main.loadNibNamed("SomeNib", owner: self, options: nil)?.first as? SomeNib navigationItem.titleView = titleView titleView is just a usual nib. then for enabling interaction: if let titleView = self.navigationItem.titleView { let

custom titleView of navigationItem is not getting tapped on iOS 11

老子叫甜甜 提交于 2020-01-24 13:02:06
问题 I am using a custom titleView and assigning it to navigationItem titleView. It had been working fine until iOS 11. Since the update it's position got misplaced to center as originally it was on more left. Beside that user interaction is not working. titleView = Bundle.main.loadNibNamed("SomeNib", owner: self, options: nil)?.first as? SomeNib navigationItem.titleView = titleView titleView is just a usual nib. then for enabling interaction: if let titleView = self.navigationItem.titleView { let

Is it possible to use core data (Xcode 8 and Swift 3.0) with both iOS 9 and 10 ?

巧了我就是萌 提交于 2020-01-24 12:48:33
问题 I want start new app in Swift 3 Xcode 8 and support iOS 8.4/9.x How to deal with Core Data ? 回答1: Yes, it is easily possible. Swift 3 is targeted to run on iOS v8+. You will only be able to use the subset of APIs supported on iOS v8.4 though. The best way to find out the answer to your question though is to create a test project that uses Core Data. You'll find that NSPersistentContainer creates an error. Why? It isn't available on the earlier OSes. Alternatively, create a test project with

Get local notification's body text or identifier in AppDelegate Swift

╄→гoц情女王★ 提交于 2020-01-24 11:43:47
问题 I want to access my application data in AppDelegate.swift whenever the app receives an action response. I was trying to use the func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { if response.actionIdentifier == "check" { //do something to the app's data } completionHandler() } method, but I can't locate the data because I can't get the notification's identifier nor its

Get local notification's body text or identifier in AppDelegate Swift

感情迁移 提交于 2020-01-24 11:43:27
问题 I want to access my application data in AppDelegate.swift whenever the app receives an action response. I was trying to use the func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { if response.actionIdentifier == "check" { //do something to the app's data } completionHandler() } method, but I can't locate the data because I can't get the notification's identifier nor its

AVAudioPlayerNode doesn't play sound

烂漫一生 提交于 2020-01-24 09:20:10
问题 I'm trying to generate sound with code below. Everthing is fine there is no error. But when I executed this code, there is no sound. How can I fix this problem ? By the way, I'm using this example : http://www.tmroyal.com/playing-sounds-in-swift-audioengine.html var ae:AVAudioEngine var player:AVAudioPlayerNode? var mixer:AVAudioMixerNode var buffer:AVAudioPCMBuffer ae = AVAudioEngine() player = AVAudioPlayerNode() mixer = ae.mainMixerNode; buffer = AVAudioPCMBuffer(pcmFormat: player!

How to draw a directional arrow head

感情迁移 提交于 2020-01-24 00:33:17
问题 I have lines in many directions and angles, I draw them using UIBezierpath . I need to draw an arrow on one of the ends of the line; dynamically depending on given point. Edit: Edit 2: with Jake answer here is my code let y2 = line.point2Y let path = UIBezierPath() path.move(to: CGPoint(x: x1, y: y1)) path.addLine(to: CGPoint(x: x2, y: y2)) path.addArrow(start: CGPoint(x: x1, y: y1), end: CGPoint(x: x2, y: y2), pointerLineLength: ... path.close() let shape = CAShapeLayer() let shapeBorder =

(setValue:) Cannot store object of type _SwiftValue at pictureURL. Can only store objects of type NSNumber, NSString, NSDictionary, and NSArray

我与影子孤独终老i 提交于 2020-01-23 07:27:07
问题 Having some issues understanding firebase with Swift 3. I've remade my observer to look like this: currentUserFirebaseReference.observeSingleEvent(of: .value, with: { (snapshot: FIRDataSnapshot) in let UID = snapshot.key let dict = snapshot.value as! Dictionary<String,AnyObject> let pictureURL = dict["pictureURL"] as! String I used to just do observation..... in { let picture = snapshot.value!["pictureURL"] But now I guess you have to explicitly tell Firebase that you're dealing with a

How to get start date and end date of the current month (Swift 3)

二次信任 提交于 2020-01-23 07:00:29
问题 I'm trying to get the start and end dates of the current month in dd/MM/yyyy format. I tried using extension as answered in this SO Question.But it seems like it's not what I want(the format is different and also it's giving me last month's last date and current month last but one date ). Can some one help me. Extension Class: extension Date { func startOfMonth() -> Date? { let comp: DateComponents = Calendar.current.dateComponents([.year, .month, .hour], from: Calendar.current.startOfDay(for

Swift 3: Drawing a rectangle

回眸只為那壹抹淺笑 提交于 2020-01-23 05:04:05
问题 I'm 3 days new to swift, and I'm trying to figure out how to draw a rectangle. I'm too new to the language to know the classes to extend and the methods to override, and I've looked around for sample code, but nothing seems to work (which I'm attributing to my use of swift 3). What I'm trying now is: import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let k = Draw(frame: CGRect( origin: CGPoint(x: 50, y: 50), size: CGSize(width: 100, height: