草庐IT

move_member

全部标签

swift - 从常量 : Ambiguous reference to member 'subscript' 获取值时出错

我正在使用enum和tuple以及枚举大小写的值。我无法从[String:String]常量中获取值。我不知道如何修复它,它必须是一个陷阱,但我不知道在哪里,因为key肯定是字符串:enumDictTypes:String{casesettingscaseoptionscaselocations}enumFileTypes:String{casejsoncasepList}funcgetCodebookUrlComponent()->String{varFileSpecs:(dictType:DictTypes,fileType:FileTypes,redownload:Bool)=(

swift - 带有嵌套类的 Swift 4 上的 "instance member cannot be used on type"错误

我有一个带有嵌套类的类。我试图从嵌套类中访问外部类的变量:classThing{varname:String?vart=Thong()classThong{funcprintMe(){print(name)//error:instancemember'name'cannotbeusedontype'Thing'}}}然而,这给了我以下错误:instancemember'name'cannotbeusedontype'Thing'有没有一种优雅的方法来规避这种情况?我希望嵌套类能够像闭包一样捕获词法范围。谢谢 最佳答案 你可以这样做c

iOS swift : Adding or Moving NavigationBar to bottom of the view controller

我想将导航Controller栏移动到ViewController的底部。我怎样才能完成这项工作?我试过了:self.navigationController!.navigationBar.frame=CGRectMake(0,UIScreen.mainScreen().bounds.height-50,UIScreen.mainScreen().bounds.width,50)这是移动到底部但隐藏了所有其他Controller对象并且后退按钮也没有唤醒。 最佳答案 苏杰联合国,您不应尝试将嵌入式UINavigationContro

swift - 在 Swift 3.0 中在 WhatsApp 上共享错误 : Contextual member 'urlHostAllowed' has no associated value

我刚刚将我的swift项目升级到swift3。我一直在使用下面的功能在Whatsapp上分享应用程序,但是我无法理解升级后出现的错误这是函数代码:funcshareOnWhatsapp(){leturlString="Greetings,\n\nThisistheXYZApplink,Ihopeyoufindituseful!\n\nhttp://itunes.apple.com/app/idxxxxxxxx"leturlStringEncoded=urlString.addingPercentEncoding(withAllowedCharacters:.urlHostAllowed

swift - 在 Swift 中获取错误 Ambiguous reference to member 'subscript'

字典需要扩展以获取文本键值(如果存在)。执行以下代码并成功编译:extensionDictionarywhereKey:ExpressibleByStringLiteral,Value:AnyObject{funcgetValueForKeyPath(keyValue:String)->String{return((self["item_qty"]as?Dictionary)??["":""])?["text"]??""}}但是当我对方法做一些小改动时,出现错误:"Ambiguousreferencetomember'subscript'"extensionDictionarywher

ios - "Type ' 任务。在 Swift 中键入 ' has no subscript members"错误

关闭。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭6年前。Improvethisquestion这段代码给我一个错误;类型'task.Type'没有下标成员这是我的代码:structtask{varname="Un-Named"vardesc="Un-Described"}classTaskManager:NSObject{vartasks=task[]()funcaddTask(name:S

ios - 使用 Array 而不是 NSArray 时出现错误 "ambiguous reference to member subscript"

当我尝试访问数组类型值然后出现错误时,我在可能包含数组类型值的字典中收到类似“对成员下标的模糊引用”的错误。请检查以下代码。varoccupations=["Malcolm":"Captain","Kaylee":"Mechanic","Layme":["Engineer","Docter"]]as[String:Any]occupations["Jayne"]="PublicRelations"vararrOfLayme=occupations["Layme"]as!Array//gettingerrorhere,IfIuseNSArrayinsteadofarrayallwillw

ios - PDFKit : How to move current page in PDFView to a specific offset

假设PDF中只有一页。我想要实现的目标:保存当前正在查看的PDF页面的缩放和偏移量,并在用户返回该页面时以完全相同的偏移量和缩放级别显示该页面。我取得的成就:计算偏移和缩放以及页面重新加载,成功显示已保存的页面缩放级别。我无法设置偏移量。尝试使用以下方法,但没有效果。1)[_pdfViewgoToRect:rectonPage:[_pdfView.documentpageAtIndex:page.unsignedLongValue]];2)PDFDestination*destination=[_pdfView.currentDestinationinitWithPage:[_pdfV

swift - SceneKit 相机动画 move 和减速

我正在使用以下代码沿z轴moveSCNScene场景的相机节点:letmoveTo=SCNAction.moveTo(SCNVector3(x:0,y:0,z:-40),duration:40);cameraNode.runAction(moveTo)我希望给定一个事件(比如我的游戏触发的GameOver事件)顺利进行使相机减速直到停止。如何才能平稳地停止move相机? 最佳答案 SCNAction有一个“timingMode”属性,您可以将其设置为“EaseOut” 关于swift-S

ios - swift 错误 : Value of type 'NSObject -> () ' AnimalListTableViewController' has no member 'tableView'

我正试图在swiftxcode中消除这些错误如果截图太小,这里是代码importUIKitclassAnimalListTableViewController:UITableViewController{overridefunctableView(tableView:UITableView,numberOfRowsInSectionsection:Int)->Int{return4}letindexPath=self.tableView.indexPathForSelectedRow()//thisiswheretheerrorappears,itsaysValueoftype'NSO