Tag: 迅速

chartValueSelected永远不会被调用

我在我的项目中使用https://github.com/danielgindi/Charts 。 这是我的代码,这是我声明我的ViewController类: class ViewController: UIViewController, ChartViewDelegate chartView的声明 @IBOutlet weak var chartView: LineChartView! 里面viewDidLoad() self.chartView.delegate = self 这是我如何实现委托方法 func chartValueSelected(chartView: ChartViewBase, entry: ChartDataEntry, dataSetIndex: Int, highlight: Highlight) { print(dataSetIndex) } 出于某种原因,当我滑过图表时,这个方法永远不会被调用。 任何想法,为什么这可能发生? 提前致谢

将个人资料图片设置为Firebase用户的最佳方法是什么?

在我的应用程序中,我使用Firebase用户身份validation(使用电子邮件和密码)注册了用户名和个人资料图片 。 在文档之后,我像这样签署用户: let username = usernameField.text!.trimmingCharacters(in: .whitespacesAndNewlines) let profileImage = profileImageView.image! // Sign up FIRAuth.auth()?.createUser(withEmail: email, password: password, completion: { (user, error) in if user != nil { // Success let changeRequest = user!.profileChangeRequest() changeRequest.displayName = username // changeRequest.photoURL = ? … } else { if error != nil { print(error!.localizedDescription) } } }) […]

无法将数据发送到特征

当远程设备更改特征值时,我可以在应用程序上得到通知,但是当应用程序更新值时,远程设备将不会看到它。 所以,我知道我的特点是有效的,我也知道其他应用程序能够回写到这个特性(实际的设备打印它) 所以问题当然是在应用程序 。 更有趣的是,每个特征都有句柄 ,每个特征都有自己的UUID。 iOS只会让我看到我的特征UUID,不能访问它的句柄,尽pipe每个特征有两个句柄,不同的UUID 无论如何,在这里我得到callback,并试图回信: func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) { print("UPDATE FROM:" , characteristic) //good! sendData(data: "check") //not good if characteristic.uuid.uuidString == characteristicUUID { if let str = NSString(data: characteristic.value!, encoding: String.Encoding.utf8.rawValue) { print("BLE:GOT:",str ) NotificationCenter.default.post(name: Notification.Name(rawValue: "Bluetooth"), object: str) } } } 和写作: func sendData(data:String) { […]

SerializationFailure在使用Alamofire发布数据时发生错误

我试图使用Alamofire保存一些文本数据和图像到服务器,但我得到以下错误: FAILURE:responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(Error Domain = NSCocoaErrorDomain Code = 3840“Invalid value around character。”UserInfo = {NSDebugDescription =字符0周围的值无效。 我的代码: internal func postContent(forApi Name:String, image:UIImage?, withData payload:[String: String], success: ((_ response:[String: AnyObject])->Void)?, failure: ((Error)->Void)?) { //create Alamofire request //if everything was fine call success block with people array passed into it //if failure occurred, call failure block with error. if(isConnectedToNetwork()){ […]

检查字典数组是否已经有一个元素

我有一个字典,我正在添加像这样的值… var mydictionary = ["id": "", "quantity": "","sellingPrice":""] as [String : Any] dictionary["id"] = product?.id dictionary["quantity"] = product?.quantity dictionary["sellingPrice"] = product?.theRate 而我把这些值添加到像这样的数组… self.arrayOfDictionary.append(mydictionary) 但是,如果arrayOfDictionary已经包含mydictionary ,我不想添加它。 否则,我想添加它。 我不确定如何实现这一点。 希望有人能帮助…

Firebase,Swift:`runTransactionBlock()`返回null

每次我运行runTransactionBlock它给我空 ,虽然有一个节点在那个位置: – FIRMutableData(最上面的事务)(null) 在线上: – print(totalPost) func updateTotalNoOfPost(){ let prntRef = FIRDatabase.database().reference().child("TotalPosts") prntRef.observeSingleEventOfType(.Value, withBlock: {(totalSnap) in if totalSnap.exists(){ prntRef.child("noOfTotalPost").runTransactionBlock({ (totalPost: FIRMutableData) -> FIRTransactionResult in print(FIRAuth.auth()!.currentUser!.uid)//Giving me correct userID print(totalPost)//<Null> print(prntRef.child("noOfTotalPost"))//Giving me correct path to that node totalPost.value = totalPost.value as! Int + 1 return FIRTransactionResult.successWithValue(totalPost) }, andCompletionBlock: { (err, TF, snap) in print(err?.localizedDescription) print(TF) […]

如何在swift中以编程方式更改应用程序的Localizablestring文件?

我有一个应用程序,与两种语言阿拉伯语和英语。 我做了Localizablestring文件一个为每个,它正常工作,当我改变系统语言的应用程序的语言正在改变,但我需要这样做,当用户按下button来改变应用程序语言,而仍然在它。

Swift – HTTP加载失败(错误代码:-1005 ),同时通过alamofire上传图片。

我是iOS的新手,并使用Alamofire上传图片。 我写的代码如下: let image = imageView.image let imgData = UIImageJPEGRepresentation(image!, 0.2)! let headers: HTTPHeaders = [ "x-access-token": "######", "Accept": "application/json" ] let parameters = ["profile_picture": "kinza"] let url = try! URLRequest(url: URL(string:"######")!, method: .post, headers: headers) Alamofire.upload(multipartFormData: { multipartFormData in multipartFormData.append(imgData, withName: "profile_picture",fileName: "kinza.jpg", mimeType: "image/jpg") for (key, value) in parameters { multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: […]

SequenceType生成器通用Swift

我有一些问题试图运行这个代码,我发现几个使用相同的代码的例子,但我得到编译器错误 架构arm64的未定义符号:ExpSwift.SearchResults.generate() – > Swift.IndexingGenerator <[A]>,引用自:ExpSwift_Example.ViewController。(viewDidLoad() – >())。(closure#1)。closures#3)在ViewController.o ld:符号(s)找不到体系结构arm64 clang:错误:链接器命令失败,退出代码1(使用-v看到调用) 这是我的代码类 public final class SearchResults<T> { var results = [T](); let total: Int64 required public init?(results: [T], total: Int64) { self.results = results self.total = total } public func getResults() -> [T] { return self.results } public func getTotal() -> Int64 { return self.total } […]

PayPal iOSnetworking连接丢失

我实际上在PayPal Repository GitHub上发布了这个问题,但没有人回答我。 当使用PayPal账户时,PayPal SDK工作的很好,但是当我尝试使用Pay with PayPal时,我无法连接到PayPal服务器,并且没有debugging日志,只有这个: 2016-07-18 10:00:03.447 UPlant [23489:265771] NSScanner:无string参数2016-07-18 10:00:04.036 UPlant [23489:265771]无法find支持键盘iPhone-肖像,数字小; NSScanner:nilstring参数2016-07-18 10:00:04.077 UPlant [23489:265771] NSScanner:nilstring参数2016- 07-18 10:00:04.077 UPlant [23489:265771] NSScanner:nilstring参数2016-07-18 10:00:08.415 UPlant [23489:265771]无法find支持键盘types4的keyplane iPhone-Portrait-数字小; 使用563160167_Portrait_iPhone-Simple-Pad_Default 2016-07-18 10:00:10.070 UPlant [23489:265771]无法find键盘iPhone-Portrait-NumberPad支持types4的键盘; 使用563160167_Portrait_iPhone-Simple-Pad_Default 附加信息 模式(模拟/沙盒/现场) :沙盒 PayPal iOS SDK版本:沙盒,PayPal iOS SDK 2.14.2 iOS版本和设备(iOS 8.x,iPhone 6s上的iOS 9.3等): iOS 9.3 iPhone 5模拟器 PayPal-Debug-ID(来自任何日志):没有debugging日志 尝试贝宝与卡交易后,它popup一个警告说 networking连接丢失。 […]