swift3

Swift 3: Drawing a rectangle

泄露秘密 提交于 2020-01-23 05:02:58
问题 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:

Drawing Smooth Curve

戏子无情 提交于 2020-01-23 03:35:06
问题 I have two points left and right by adding some static value to Y and X is AVG of both left and right I have create 3rd point centre After that I draw curve using bezier path between them And all works fine. In above curve Now I want to create two more points (5 Points curve). One Between centre and left and one between centre and right . I tried to take again Average and draw 5 Point curve using func drawFivePoint(_ startPoint: CGPoint?, leftCenterPoint: CGPoint?, toControlPoint controlPoint

fatal error: Index out of range when refreshing table view

試著忘記壹切 提交于 2020-01-23 01:41:09
问题 I've this weird app crash when pulling to refresh occurs. My code goes as it follows: var posts: [Posts] = [] override func viewDidLoad() { super.viewDidLoad() // refreshControl -> pull to refresh handler let refreshControl = UIRefreshControl() refreshControl.addTarget(self, action: #selector(Main_TVC.getData), for: UIControlEvents.valueChanged) self.refreshControl = refreshControl getData() } override func numberOfSections(in tableView: UITableView) -> Int { return 1 } override func

Swift 3: popToViewController not working

走远了吗. 提交于 2020-01-23 01:35:33
问题 In my app I have three table view controllers and then potentially many UIViewControllers each of which has to lead back to the first table view controller if the user presses back at any point. I don't want the user to have to back through potentially hundreds of pages. This is what I amusing to determine if the user pressed the back button and it works the message is printed override func viewWillDisappear(_ animated: Bool) { if !movingForward { print("moving back") let startvc = self

How to send Image with firebase Push Notification using swift 3

安稳与你 提交于 2020-01-22 20:27:47
问题 Can any one help me to send notification like this: I'm using Firebase Notifications. I tried to put the image URL in value of Advanced options and key 1 when I send my notification. The image URL appears in the debugger, but no image appears when notification appears in my device. This is My Code. import UIKit import UserNotifications import Firebase import FirebaseInstanceID import FirebaseMessaging @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window:

How to get response after integrating UPI using hyperlink

孤街醉人 提交于 2020-01-22 18:56:07
问题 In my iOS application, I need to accept payments from the user. I am using UPI for the same. I have followed the following document provided by UPI http://www.npci.org.in/documents/UPI-Linking-Specs-ver-1.1_draft.pdf I have created a deeplink as stated in the document. UIApplication.shared.open is used to open the deeplink url so that it opens any installed PSP(Payment Service Provider) application in my phone(like PhonePe, BHIM etc) func payButtonClicked() { guard let urlString = "upi://pay

How to send total model object as a parameter of Alamofire post method in Swift3?

那年仲夏 提交于 2020-01-22 14:51:10
问题 I have a model class like this class Example() { var name:String? var age:String? var marks:String? } I'm adding data to that model class let example = Example() example.name = "ABC" example.age = "10" example.marks = "10" After that I converted to JSON then I posted Alamofire.request(URL, method:.post, parameters: example) Alamofire not accepting parameters only its accepting like parameters = ["":"","",""]-->key value based , so I tried to convert model to JSON, JSON to dictionary, even

How to load a PDF from a Base64 string in a UIWebView

对着背影说爱祢 提交于 2020-01-22 01:10:24
问题 I'm using an API that is returning a Base64 string, something like this: data:application/pdf;base64,**BASE64STRING** Where BASE64STRING is what I need to display the PDF. So far I only created a Data object that gets the Base64 string: let data = Data(base64Encoded: BASE64STRING) And I tried to load it in the webview: webView.load(data!, mimeType: "application/pdf", textEncodingName: "", baseURL: URL(string: "")!) The problem is that I don't have a local PDF file, so I don't know what I

Run custom shell script '[cp] embed pods frameworks' no such file or directory

巧了我就是萌 提交于 2020-01-20 21:43:27
问题 Just finished resolving my errors after converting to Swift 3 only to get this error when trying to compile. I have attached a screenshot for clarity, it does not look like the system is looking for a .app file or .sh file. Really don't know too much about the Pods, so any help would be greatly appreciated! 回答1: Seem to have found a solution. My project name had a space in the middle of two words, very bad practice I know. Not entirely sure what caused this error, though one could possibly

Change size of UIBarButtonItem (image) in Swift 3

妖精的绣舞 提交于 2020-01-20 21:03:48
问题 I am trying to change the size of some icons in my navBar, but I am a little confused as to how to do this? My code so far is: func setUpNavBarButtons() { let moreButton = UIBarButtonItem (image: UIImage(named:"ic_more_vert_3")?.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(handleMore)) navigationItem.rightBarButtonItems = [moreButton] let refreshButton = UIBarButtonItem (image: UIImage(named:"ic_refresh")?.withRenderingMode(.alwaysOriginal), style: .plain