草庐IT

swift-modules

全部标签

ios - 使用 swift3 为 xib 文件中的按钮提供操作

已提供:我的xib中有一个按钮与此相关的swift文件也已附上。问题:此单元格有一个按钮,需要在单击按钮时显示ViewController。此单元格附加到另一个ViewController中的TableView。我想在“BOOK”按钮上执行一个操作,以便在单击时打开新的ViewController。我无法做到这一点,有人可以建议我做些什么吗?代码:importUIKitclassHotelBookingCell:UITableViewCell{@IBOutletweakvarBookbtnOutlet:UIButton!overridefuncawakeFromNib(){super.

ios - 将用户重定向到特定的 ViewController - Swift 4

我试图在删除该地点后将用户重定向到正确的页面。navigationController?.popToRootViewController(animated:true)如果我想重定向到根目录,这将起作用。navigationController?.popViewController(animated:true)如果我想重定向到上一个,这将起作用但在我的例子中,我想重定向到一个特定的页面,而不是根页面或前一个页面。如何在iOS中着手做这样的事情? 最佳答案 如果你现在在你的堆栈中的位置你也可以使用self.navigationContr

ios - 如何在 xcode 7 的 Swift 2.0 中使用 NSRegularExpression

//错误在这里letregex=NSRegularExpression(pattern:"()",options:nil,error:nil)//错误是:***cannotfindaninitializerfortypensregularexpressionthatacceptanargumentoftype(pattern:string,ption:nil,error:nil) 最佳答案 Swift2.0中的语法有2处变化:(1)您将调用包装在try...catchblock中,而不是提供error范围;(2)options应该是

ios - swift 3.0 中的 Sha 256 加密语法错误

funcSHA256()->String{letdata=self.data(using:String.Encoding.utf8)letres=NSMutableData(length:Int(CC_SHA256_DIGEST_LENGTH))CC_SHA256((data!asNSData).bytes,CC_LONG(data!.count),UnsafeMutablePointer(res!.mutableBytes))lethashedString="\(res!)".replacingOccurrences(of:"",with:"").replacingOccurrenc

Swift 变量、常量和数据类型

欢迎您阅读 MasteringSwift 基础教程,本文我们将介绍Swift中的变量、常量和数据类型。如果你尚未安装Xcode和配置Swift开发环境,请您先阅读这篇文章。接下来,我们启动Xcode,然后选择"File">"New">"Playground"。创建一个新的Playground并命名为"Variables"。声明和使用变量在Swift使用 var 关键字定义变量。变量值可以在其生命周期中被改变。而在TypeScript中,是使用 var 或 let 关键字定义变量。Swift代码varname="Kakuqo"name="Semlinker"TypeScript代码letname

ios - Swift3 圆了 UIView 的两个角

我知道这个问题已经被问过很多次了,他们的解决方案也可用,但对我来说没有任何用处。我正在使用Swift3并且我想为此目的将UIView的任意两侧四舍五入我找到了以下解决方案Createarectanglewithjusttworoundedcornersinswift?下面是我上述解决方案的代码片段extensionUIView{/**Roundsthegivensetofcornerstothespecifiedradius-parametercorners:Cornerstoround-parameterradius:Radiustoroundto*/funcround(corner

ios - swift : Is there a way to test if object cast as AnyObject conforms to Equatable?

我有一个具有键控属性的对象:funcvalue(key:String)->AnyObject?funcsetValue(value:AnyObject?,key:String)我想检查从具有来自两个不同对象的相同键的value函数返回的值是否Equatable。Swift提示是因为Equatable有一个Self引用并且只能在泛型中使用。有没有一种方法可以检查从value函数返回的AnyObject对象是否符合Equatable? 最佳答案 由于Swift2的变化,我正在编辑我的答案要检查协议(protocol)一致性,只需使用is

ios - Facebook SDK FBSession 代码不适用于 Swift

尝试在Swift中实现这个ObjectiveC代码://Wheneverapersonopenstheapp,checkforacachedsessionif(FBSession.activeSession.state==FBSessionStateCreatedTokenLoaded){//Ifthere'sone,justopenthesessionsilently,withoutshowingtheusertheloginUI[FBSessionopenActiveSessionWithReadPermissions:@[@"public_profile"]allowLoginU

ERROR: An error occurred while performing the step: “Building kernel modules“. See /var/log/nvidia-i

目录错误:在执行步骤“构建内核模块”时发生了错误。详细信息请参阅/var/log/nvidia-installer.log日志。1.检查NVIDIA安装程序日志2.验证内核头文件和开发包3.禁用安全启动(SecureBoot)4.使用DKMS(动态内核模块支持)5.在NVIDIA支持论坛寻求帮助结论ERROR:Anerroroccurredwhileperformingthestep:"Buildingkernelmodules".See/var/log/nvidia-installer.logfordetails.错误:在执行步骤“构建内核模块”时发生了错误。详细信息请参阅/var/log/

遇到Error: Cannot find module ‘..\node_modules\@angular\cli\bin\ng‘怎么解决

有时候我们在项目工程里已经安装了@angular/cli,但是使用ng命令时还是会抛错,提示找不到模块,这时候我们可以尝试先全局卸载angular/cli,然后再重新安装。PSD:\workspace\contact>ngservenode:internal/modules/cjs/loader:936throwerr;^Error:Cannotfindmodule'C:\Users\***\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng'atFunction.Module._resolveFilename(node:internal/