草庐IT

Swift-Firebase

全部标签

ios - Swift - HTTP 加载失败(通过 alamofire 上传图像时错误代码 : -1005 [4:-4]),。

我是iOS新手,使用Alamofire上传图片。我写的代码如下:letimage=imageView.imageletimgData=UIImageJPEGRepresentation(image!,0.2)!letheaders:HTTPHeaders=["x-access-token":"######","Accept":"application/json"]letparameters=["profile_picture":"kinza"]leturl=try!URLRequest(url:URL(string:"######")!,method:.post,headers:hea

ios - 在使用 firestore(firebase 云数据库)获取重复数据时

我正在使用设置限制的firestore数据在tableview中加载更多功能,同时我滚动tableview获取addListener方法调用,我检查两次,获取重复记录。在下面的代码中,我已经打印了我得到的快照。每次我滚动时,它都会按快照ID及其数据打印。仍然得到重复数据。Firebase控制台是否有任何其他设置?这是我的代码,但代码没有任何错误,它来自firebase。funcgetTasks(){//self.tableViewData.reloadDataWithLoader(true)letuserID=HelperFunction.helper.FetchFromUserDef

iOS swift : Constraints did not update on screen

晚上,ScrollView约束有问题。这是我的代码://whenthekeyboardisshown,moveupsomeelements@objcfunckeyboardWillShow(notification:NSNotification){ifletkeyboardSize=(notification.userInfo?[UIKeyboardFrameEndUserInfoKey]as?NSValue)?.cgRectValue{//Bringupthescrollviewprint(scrollViewBottomConstraint.constant)self.scroll

ios - Swift 4 中的 mapView.setRegion

我在Swift4、Xcode9中的代码有问题。有人可以帮助我吗?当我运行这个程序时,它给我一个错误。它说mapView.setRegion(region,animated:true)不工作并给我一个错误,当我注释掉它时,它适用于我的当前位置,但只是没有紧密放大。funclocationManager(_manager:CLLocationManager,didUpdateLocationslocations:[CLLocation]){letlocation=locations[0]if!isInitialized{isInitialized=trueletspan:MKCoordin

ios - 如何使用 Firebase 在 UITableViewController 中正确显示数据?

我正在构建类似“instagram”应用程序的东西,其中包含带图片的帖子。我正在使用Firebase来存储/检索数据。我的问题是因为帖子以随机方式显示。例如,在cellForRowAtIndexPath中,第一篇文章显示在indexPath[0],下一篇文章是[1],但下一篇应该在[2],它显示在[0].我将复制粘贴与该问题最相关的代码:这是我检索分数的类://////ArraystostorethedatanameArray=[[NSMutableArrayalloc]init];scoreArray=[[NSMutableArrayalloc]init];photomealArra

ios - Swift 3 和 Firebase 观察 Child 是否存在

需要观察我的Firebase数据库中的一个节点(如果它存在)。我使用的代码是这样的:varCOLOR_REF=Database.database().reference().child("Colors")self.COLOR_REF.child(id).observe(.childAdded){(snapshot)inletkey=snapshot.keyApi.Post.getMyPosts(withId:key,completion:{(post)incompletion(post)})}id可能存在也可能不存在...我需要的是执行观察ifchild(id)existelsedos

ios - 在 Swift 4.0 中获取上个月趋势存储库时出错 - Github API

我正在将以下curl翻译成Swift但不幸的是,我在PlayGround上运行时遇到以下错误:Optional(["errors":({code=invalid;field=q;message="\"`date\"isnotarecognizeddate/timeformat.PleaseprovideanISO8601date/timevalue,suchasYYYY-MM-DD.";resource=Search;}),"documentation_url":https://developer.github.com/v3/search/,"message":ValidationFa

ios - 带有 UICollectionView 的 UITableViewCells 低性能(Swift)

我有一个tableview,每个单元格中嵌套了一个collectionView。tableViewCell的数量是动态的,每个tableViewCell的collectionViewCell的数量也是动态的。我“dequeueReusableCell”这两种细胞。每次加载tableViewCell时,我都会执行cell.collectionView.reloadData()。当我滚动TableView时,它真的很乱。此外,viewController需要大量加载。我试图在uitableviewcell的prepareforReuse或willDisplayCell中移动collecti

ios - 使用 AVCaptureVideo 在 Swift 中捕获 240 fps 的视频

我想在我的iPhone显示屏上看到240fps的视频预览。我的代码(简单)是这样的(如下):进行session,激活相机,并在显示屏上显示实际的视频预览。varsession:AVCaptureSession?varstillImageOutput:AVCaptureStillImageOutput?varvideoPreviewLayer:AVCaptureVideoPreviewLayer?overridefuncviewDidLoad(){super.viewDidLoad()super.viewWillAppear(true)session=AVCaptureSession()

IOS - 未从 firebase 控制台收到 FCM 推送通知

我有一个nativeios应用程序,它启用了FCM。我已经将证书上传到firebase并从appdelegate将GoogleService-Info.plist添加到我的项目中-(void)application:(UIApplication*)applicationdidRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken{[FIRMessagingmessaging].APNSToken=deviceToken;NSLog(@"FCMdeviceToken:%@",deviceToken);}AndI