草庐IT

swift_FORCE_LOAD

全部标签

ios - 使用 Swift 3 #keyPath 引用 UIView 子类 .center

在我的应用程序的ViewController中,我通过观察其center属性的键值对View定位的更改使用react,如下所示:classCoordinatingViewController:UIViewController{@IBOutletweakvarcardContainerView:CardView!overridefuncviewDidLoad(){super.viewDidLoad()addObserver(self,forKeyPath:"cardContainerView.center",options:[.new],context:nil)}}这目前工作得很好,但由

ios - 如何以编程方式设置字体大小以适应 swift 4 中的行数值

我有两个名为headingLabel和descriptionLabel的UILabel,它们的行数分别为3和5。现在我希望文本的字体大小发生变化并适合numberOfLines,其中文本根据收到的一些网络json数据而变化。hereismycodeletheadingLabel:UILabel={lethl=UILabel()hl.translatesAutoresizingMaskIntoConstraints=falsehl.text="LoremipsumdolorsitametLoremipsumdolorsitametametLoremipsumdolorsitametame

ios - Swift - Firebase - 身份验证电子邮件无密码

我正在尝试使用Firebase(Swift)进行电子邮件/无密码身份验证https://firebase.google.com/docs/auth/ios/email-link-auth在文档中,他们提到了这个设置:letactionCodeSettings=ActionCodeSettings()actionCodeSettings.url=URL(string:"https://www.example.com")//Thesign-inoperationhastoalwaysbecompletedintheapp.actionCodeSettings.handleCodeInApp

swift - 如何通过代码在 SceneKit 中设置基于物理的渲染?

我想用PBR呈现一些场景。我创建了金属度和粗糙度纹理并想将其应用于网格。当我尝试在Xcode中执行此操作时-一切都很好。我可以将这个模型添加到场景中,然后将这个纹理添加到模型中。但我想以编程方式进行。这是我的代码:NSData*vertices=[[NSDataalloc]initWithBytes:modelPly->verticeslength:modelPly->vertexCount*3*sizeof(float)];SCNGeometrySource*vertexSource=[SCNGeometrySourcegeometrySourceWithData:verticess

swift - Realm Swift - 枚举值 'connect_timeout' 和 'bad_timestamp"未在开关中处理

我刚刚通过cocoapods更新到Xcode9.4(Swift4.1)和Realm3.6.0。我第一次收到编译器“语义问题”警告:Enumerationvalues'connect_timeout'and'bad_timestamp'nothandledinswitch我已经清理了构建文件夹并重新构建,但没有成功。警告仍然存在。有什么想法吗?编辑:我应该提到警告在RealmFramework中。具体来说,sync_session.cpp:switch(static_cast(error_code.value())){caseClientError::connection_closed:

ScrollView 下的iOS swift 4 imageview : double tap to zoom out

我已经应用ImageView通过捏合来放大/缩小。那很容易。在ImageView上应用双击时,无法检测到选择方法。我使用Xcode9和swift4。你能告诉我ScrollView是否应该应用双击手势吗?varpreviewImage:UIImage?=niloverridefuncviewDidLoad(){super.viewDidLoad()scrollView.minimumZoomScale=1.0scrollView.maximumZoomScale=6.0imageView.image=previewImageletdoubleTap=UITapGestureRecogni

swift - 有没有办法知道 Swift 是如何计算 hashValue 的?

我最近发现下面的代码以散列冲突告终。仅供引用,我使用的是XCode9.4.1(9F2000),它使用Swift4.1.2importFoundationletlhs="あいうえおあいう21あいうえ"letrhs="あいうえおあいう22あいうえ"letpercentEncodedLhs=lhs.addingPercentEncoding(withAllowedCharacters:.urlPathAllowed)!letpercentEncodedRhs=rhs.addingPercentEncoding(withAllowedCharacters:.urlPathAllowed)!le

swift - AppDelegate 类型的值在 swift 4 中没有成员 managedObjectContext

我有代码:letappDel:AppDelegate=UIApplication.shared.delegateas!AppDelegateletcontext:NSManagedObjectContext=appDel.persistentContainer.viewContext但是xcode报错:ValueoftypeAppDelegatehasnomembermanagedObjectContext.我想找到一个解决方案,非常感谢。 最佳答案 请使用下面的代码importCoreDataframeworkfuncapplic

swift - 如何为不同类型定义通用“无效”值

在我的应用程序中,我使用整数、double、float和CGFloats来表示许多不同的值。根据我的应用程序的语义,这些值可能会变成“无效”,我使用保留值i来表示这种状态。e.-1。使它在代码中可用的最简单方法是:anIntVariable=-1aFloatVariable=-1aDoubleVariable=-1.0...为了摆脱这种约定俗成的方法并提高可读性和适应性,我定义了一些扩展:extensionInt{staticvarinvalid=-1}extensionFloat{staticvarinvalid=-1.0}extensionDouble{staticvarinval

swift - 是否有一个快速数据结构可以包含一个可以是任何类型并且可以切换的rawValue

我需要某种可以接受任何StringLiteralType的枚举,我不需要在其中创建大量样板代码。这是我拥有的样板代码示例。enumSample:RawRepresentable{casefoocasebarcaseunknown(String)init?(rawValue:String){ifletcorrespondingValue=Key(rawValue:rawValue)?.correspondingValue{self=correspondingValue}else{self=.unknown(rawValue)}}privateenumKey:String{casefooc