草庐IT

convert_it

全部标签

swift 错误 : 'DYLD_BOOL' is not convertible to 'bool'

我正在开发一个简单的基于tableview的应用程序,如果用户触摸任何单元格,那么他将导航到DetailViewController,当用户单击DetailViewController时,他返回到我使用的tableView:overridefunctouchesBegan(touches:NSSet,withEventevent:UIEvent){self.dismissViewControllerAnimated(TRUE,completion:nil)}但是我以后不能在小的时候使用true并且那行给我这样的错误:'DYLD_BOOL'isnotconvertibleto'bool'

ios - 更新到 Xcode 6.1 后 "Use of property ' nibName ' in base object before super.init initializes it"

我的iOS应用程序中有这段代码,是用Swift编写的:classAddHomeViewController:UITableViewController,UITextFieldDelegate{...requiredoverrideinit(nibNamenibNameOrNil:String?,bundlenibBundleOrNil:NSBundle?){super.init(nibName:nibName,bundle:nibBundle)}更新到Xcode6.1后,我在super.init(nibName:nibName,bundle:nibBundle)行收到这些错误。它之前工

swift 错误 : (int) not convertible to int

这个问题在这里已经有了答案:PassinglistsfromonefunctiontoanotherinSwift(2个答案)关闭7年前。我正在阅读Apple的“Swift编程语言”指南并遇到以下问题。该书将求和函数定义为:funcsumOf(numbers:Int...)->Int{vars=0fornumberinnumbers{s+=number}returns}并包括一个“编写一个计算其参数平均值的函数”的实验,我试图重新使用sumOf来定义:funcaverageOf(numbers:Int...)->Float{varsum=sumOf(numbers)returnFloa

android - Android : How can I center its title? 上的自定义对话框

我正在开发一个Android应用程序。如何将我正在使用的自定义对话框的标题居中? 最佳答案 另一种以编程方式完成的方法是使用setCustomTitle()://CreatingtheAlertDialogwithacustomxmllayout(youcanstillusethedefaultAndroidversion)AlertDialog.Builderbuilder=newAlertDialog.Builder(this);LayoutInflaterinflater=(LayoutInflater)this.getSys

android - Android : How can I center its title? 上的自定义对话框

我正在开发一个Android应用程序。如何将我正在使用的自定义对话框的标题居中? 最佳答案 另一种以编程方式完成的方法是使用setCustomTitle()://CreatingtheAlertDialogwithacustomxmllayout(youcanstillusethedefaultAndroidversion)AlertDialog.Builderbuilder=newAlertDialog.Builder(this);LayoutInflaterinflater=(LayoutInflater)this.getSys

swift - 哪个更有效 : Creating a "var" and re-using it, 或创建多个 "let"s?

只是好奇哪个在swift中更高效/更好:创建三个临时常量(使用let)并使用这些常量定义其他变量创建一个临时变量(使用var)并使用该变量保存三个不同的值,这些值随后将用于定义其他变量也许通过一个例子可以更好地解释这一点:varone=Object()vartwo=Object()varthree=Object()funcfirstFunction(){lettempVar1=//calculation1one=tempVar1lettempVar2=//calculation2two=tempVar2lettempVar3=//calculation3three=tempVar3}f

swift 3 : Int is not convertible to Bool in bitwise operation

不确定我在这里做错了什么,但这是破坏的微不足道的代码:if10&(1这给了我:'Int'isnotconvertibleto'Bool'怎么了? 最佳答案 不像在C中你可以写...if(x){}...这实际上是一个非零检查:if(x!=0){}您必须在Swift中测试bool条件。将!=0添加到您的语句中:if10&(1 关于swift3:IntisnotconvertibletoBoolinbitwiseoperation,我们在StackOverflow上找到一个类似的问题:

swift - : in Swift function signatures and why is there no comma when it seems there should be one?是什么意思

这是我所说的示例:https://developer.apple.com/documentation/foundation/nsmutableorderedset/1410287-insert插入函数显示为insert(_:at:)实际使用时,插入函数看起来更像:namesArray.insert("John",at:3)在"John"之后没有:(虽然我想它可能是"John":String--就是它在那里的样子for?),而文档中的函数签名中没有提到实际需要去那里的,。当我实际使用它时,我是否应该知道/假设逗号在那里?所有Swift函数都是这种情况吗?请注意,这不是关于下划线_的问题—

swift - "The file "MyApp.app "couldn' t被打开,因为你在 Xcode 6 Beta 4 中运行应用程序时没有 't have permission to view it"

每当我尝试在Xcode6Beta4中运行我的应用程序时,我都会收到错误消息:Thefile"MyApp.app"couldn'tbeopenedbecauseyoudon'thavepermissiontoviewit.无论我使用什么模拟器或设备,都会出现此错误。我试过:从Xcode中的管理器中删除所有派生数据修复我的驱动器权限手动提升构建的MyApp.app的权限重新启动我的电脑有没有其他人遇到过这个问题并找到了解决方案? 最佳答案 我使用Xcode6GM。我遇到了同样的问题。我所做的是转到“build设置”->“构建选项”。然后

swift - 嵌套堆栈 View : Child Stack View is not inside its parent stack view when attaching it programmatically

我正在尝试实现嵌套堆栈View,其中一个堆栈View位于另一个堆栈View内。我的代码基于here.我当前的代码在下面。@IBOutletweakvarverticalStackView:UIStackView!letblueImageView=UIImageView()blueImageView.backgroundColor=UIColor.blueColor()blueImageView.image=UIImage(named:"justsomeimage")blueImageView.snp_makeConstraints{(make)inmake.height.width.e