草庐IT

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 - 在 iPhoneX 上设置 UITabBarController 的 ViewControllers 会错放标签

我们使用Storyboard来设置我们的UITabBarController,但使用UITabBarController的loadView()中的标签过滤相关的ViewControllers:ifletfilteredVCs=self.viewControllers?.filter({$0.tabBarItem.tag!=hiddenTag}){self.setViewControllers(filteredVCs,animated:false)}在iPhoneX之前,这一直工作正常。它会导致标签放错位置:没有这段代码它工作正常:我们已经在UITabBar上尝试了setNeedLayo

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 - XC测试 : Can not get the last collection cell element after swipeLeft()

我的表格View单元格中有一个CollectionView。我想在向左滑动后点击最后一个单元格以查看最后一个集合单元格。例如,这是我的列表CollectionView单元格:|ABCD|EFNote:'|'istheboundsofscreenandcollectioncellE,FarenotvisibleyetlettableCell=app.tables["TableView"].cells.element(boundBy:1)//TesttogetthelabelofcollectioncellinsidetableCellletcollectionCell_A=tableCe

ios - 在#selector 函数中传递数据

我无法确定点击按钮时传递数据的最佳方式。我还想在点击按钮时为按钮设置动画。该按钮位于map注释的自定义标注View内。我尝试设置一个类属性dogIDOfUpvoteTapped,并使用它来存储数据,以便被调用的函数可以访问它。不幸的是,当我想与按钮本身交互时,事情变得复杂了。如何从调用的函数“upvoteButtonTapped”中获取对“CustomAnnotation”对象的引用?我省略了一堆不相关的代码,但这是我正在使用的代码:funcmapView(_mapView:MKMapView,didSelectview:MKAnnotationView){ifview.annotat

ios - AVAudioPlayer 音频中断和音量自行增加

我在viewWillAppear中调用此函数playSound(),音频开始播放,然后音量突然增加,播放稍有中断。这是我的代码funcplaySound(){leturl=Bundle.main.url(forResource:"music",withExtension:"mp3")!do{tryself.player=AVAudioPlayer(contentsOf:url)player?.prepareToPlay()player?.numberOfLoops=-1player?.play()}catchleterrorasNSError{KBLog.log(object:erro

ios - 从 xcode 中的 Assets 目录中获取图像名称列表

这个问题在这里已经有了答案:GetlistoffolderandfileswithinAssets.xcassets(1个回答)关闭5年前。我是xCode的新手。我想从Assets目录中的文件夹创建一个UIImage数组-请参见屏幕截图(“Brands”文件夹)。像这样将其加载到UITableView中:privatefuncloadLocalBrands(){//Loadimagesnamesfromassetsandaddthemtoarrayletnames:[String]=["Avon","Dove","Faberlic","Grand","GreenLight","Lore

ios - 无法在 Apple Watch 上获取可操作通知回调

我有一个推送通知的iOS应用程序(例如,当用户进入某个地理区域时)。我还有一个Watch应用程序,可以在iPhone锁定时收到这些通知。我在这些通知中有2个操作(“调用”、“转到”),它们在AppleWatch通知中正确显示但是当用户触摸其中一个操作时回调userNotificationCenter(_center:UNUserNotificationCenter,didReceiveresponse:UNNotificationResponse,withCompletionHandlercompletionHandler:@escaping()->Void)我的UNUserNotif