草庐IT

current_index

全部标签

ios - 在哪些函数中,如何在LiquidFloatingActionButton 的index cell 中添加action?

我使用以下代码在LiduidFloatingActionButton中创建了两个按钮单元格。privatefunccreateFloatingButtons(){cells.append(createButtonCell("firstCell"))cells.append(createButtonCell("secondCell"))letfloatingFrame=CGRect(x:self.view.frame.width-56-16,y:self.view.frame.height-56-36,width:56,height:56)letfloatingButton=create

swift - 从任何 UTF-16 偏移量中,找到位于字符边界上的相应 String.Index

我的目标:给定String中的任意UTF-16位置,找到代表的相应String.Index字符(即扩展字素簇)指定的UTF-16代码单元是其中的一部分。示例:(IputthecodeinaGistforeasycopyingandpasting.)这是我的测试字符串:letstr="??‍?"(注意:要将字符串视为单个字符,您需要在能够处理Unicode9中引入的具有肤色的新职业表情符号的相当新的操作系统/浏览器组合上阅读此内容。)它是由四个Unicode标量或7个UTF-16代码单元组成的单个字符(字素簇):print(str.unicodeScalars.map{"0x\(Stri

ios - 错误 : UICollectionView received layout attributes for a cell with an index path that does not exist in Swift

我“https://www.raywenderlich.com/392-uicollectionview-custom-layout-tutorial-pinterest”创建自定义UICollectionView。(调整单元格高度)如果我向上滚动,cell会继续添加,从上往下滚动刷新。当您运行您的应用程序并最初生长Cells时没有问题。但是,刷新或重新排序单元格数量时总是出错。错误:***Assertionfailurein-[UICollectionViewDatavalidateLayoutInRect:],/BuildRoot/Library/Caches/com.apple.

ios - swift 3.0 : Unable to infer closure type in the current context , PromiseKit

我在swift3.0中有以下代码,我在其中使用PromiseKit。funccalculateTravelTime(from:CLLocation,to:CLLocation)->Promise{Promise{completion,reject->Voidinletrequest=MKDirections.Request()request.transportType=.walkingletfromPlacemark=MKPlacemark(coordinate:from.coordinate)lettoPlacemark=MKPlacemark(coordinate:to.coord

ios - 适用于 iOS 的 Google 登录 : error "Cannot subscript a value of type ' [String : AnyObject ]' with an index of type ' String'"

对于options[UIApplicationOpenURLOptionsSourceApplicationKey],“无法使用String类型的索引为类型[String,AnyObject]的值下标”。Swift2、iOS9.x、GoogleSignin使用CocoaPods安装。有什么提示吗?funcapplication(app:UIApplication,openURLurl:NSURL,options:[String:AnyObject])->Bool{returnGIDSignIn.sharedInstance().handleURL(url,sourceApplicati

ios - 没有 "Index out of Range"swift 的实时重新加载 UITableview

我试图每秒重新加载我的表格View。我现在拥有的是重新加载tableview对象,但由于我在重新加载之前清除了Order数组,它因索引超出范围而崩溃。这是我当前的代码varorders=[Order]()overridefuncviewDidLoad(){super.viewDidLoad()//tablestufftableview.dataSource=selftableview.delegate=self//updateordersvartimer=Timer.scheduledTimer(timeInterval:4,target:self,selector:"GetOrder

ios - UIDevice.current.setValue(value, forKey : "orientation") does not work if phone held in landscape and tilted 45 - 90 degrees

我在用letvalue=UIInterfaceOrientation.landscapeRight.rawValueUIDevice.current.setValue(value,forKey:"orientation")强制呈现ViewController以横向显示。这是导航Controller流程的一部分。这按预期工作,但如果手机横向放置并倾斜45到90度,View将以纵向显示。该方法被调用并且预期值是正确的,但景观没有发生变化。这可以在带有导航Controller的基本项目中重现。有谁知道是什么导致了这种行为? 最佳答案 我也

ios - Swift 中的 NSDictionary :Cannot subscript a value of type 'AnyObject?' with a index of type 'Int'

所以我正在尝试使用swift解析JSON中的一些数据。下面是我的代码varjsonResult:NSDictionary!=NSJSONSerialization.JSONObjectWithData(data,options:NSJSONReadingOptions.MutableContainers,error:nil)as!NSDictionaryprintln(jsonResult)上面的代码会返回这样的东西{count=100subjects=({alt="....."name="....."},{alt="....."name="....."},......)}然后我尝试使

ios - Locale.current 在设备上报告错误的语言

我正在尝试在iOS应用程序中设置货币值的格式,并且我正在使用设备上的当前区域设置来使用适当的货币格式。在模拟器中,一切似乎都运行良好:当使用currencyFormatter.locale=Locale.current时,它采用正确的区域设置并以正确的货币格式打印数字。然而,在我的iPhone上,它以法语配置并具有法国区域设置,我希望使用另一种格式(例如:1234,56€)。但它不起作用,并且似乎使用了英文格式样式(例如:€1234,56)。事实上,如果我在设备上打印我的应用程序的当前语言环境,它不会像我期望的那样返回fr_FR:NSLog(Locale.current.identif

ios - 转换为 Swift 3 错误 : "Convert to Current Swift Syntax Failed Could not find test host for..."

当我尝试运行在升级到Xcode8之前完美运行的项目时,我不断收到错误“UseLegacySwiftLanguageVersion”(SWIFT_VERSION)isrequiredtobeconfiguredcorrectlyfortargetswhichuseSwift.Usethe[Edit>Convert>ToCurrentSwiftSyntax…]menutochooseaSwiftversionorusetheBuildSettingseditortoconfigurethebuildsettingdirectly.尝试转换为swift3.0后,我不断收到错误消息:Conve