草庐IT

filling_values

全部标签

ios - swift 错误 : Could not cast value of type 'NSTaggedPointerString' (0x1a1264378) to 'NSNumber' (0x1a126f900)

我在Xcode(swift)中遇到这个错误:Couldnotcastvalueoftype'NSTaggedPointerString'(0x1a1264378)to'NSNumber'(0x1a126f900).我用//ERROR:("...")明确了错误在哪里代码:importUIKitimportiAdimportAVFoundationimportAudioToolboxletMAX:UInt32=4letMIN:UInt32=1classViewController:UIViewController,ADBannerViewDelegate{varchances=10varw

swift - 错误 : cannot convert value of type '() -> ()' to closure result type 'String' using Swift + PromiseKit

我不熟悉Swift中的promise,并使用PromiseKit尝试在Playground上创建一个非常简单的响应并尝试使用它。我有以下代码:importUIKitimportPromiseKitfuncfoo(_error:Bool)->Promise{returnPromise{fulfill,rejectinif(!error){fulfill("foo")}else{reject(Error(domain:"",code:1,userInfo:nil))}}}foo(true).then{response->Stringin{print(response)}}但是我得到以下错误

swift - 为 uibutton Swift 的背景图像分配 "aspect fill"选项

我们可以通过以下方式将按钮的图像设置为纵横比填充:imageView?.contentMode=UIViewContentMode.ScaleAspectFill但由于我正在处理背景图像,所以我不确定如何访问背景图像的contentMode。我知道不这样做,我可以创建一个自定义类,其中图像可以居中,按钮文本在顶部居中,然后使用上面的代码将imageview设置为纵横比填充,但这似乎要多得多努力实现相同的结果。完成此任务的最佳方法是什么? 最佳答案 问问题已经很久了,但有人想知道,如果你使用setImage()设置你的按钮图像,无论你

ios - alamofire post 方法中的 response.result.value 为 nil

letparametersDictionary=["email":"name@gmail.com","password":"password"]Alamofire.request("http://nanosoftech.com/store/user_check",method:.post,parameters:(parametersDictionaryasNSDictionary)as?Parameters,encoding:JSONEncoding.default,headers:nil).responseJSON{responseinprint("response:",respon

IOS FoodTracker 教程 : Value of tuple type '()' has no member 'path'

我正在完成IOSSwift教程“FoodTracker”,但是有一个错误我可以找到解决方案,但我不明白哪里出了问题以及如何解决它:错误:Valueoftupletype'()'hasnomember'path'此错误在以下代码中针对变量“Meal.ArchiveUrl.path”显示。我的代码,在MealtableViewController(相当于IOS教程):privatefuncsaveMeals(){letisSuccessfulSave=NSKeyedArchiver.archiveRootObject(meals,toFile:Meal.ArchiveUrl.path)if

ios - Obj-C 框架返回 nil,并使我的 Swift 代码崩溃并显示 'fatal error: unexpectedly found nil while unwrapping an Optional value'

我正在使用用Obj-C编写的第三方框架,它有一个功能:-(NSError*)generateModelForm如果此方法成功,它将返回nil。如果它不返回nil,它将返回一个错误,您可以检查该错误以进行调试。现在,当我使用桥接头在我的Swift文件中调用此函数并执行所有必需的操作时,它总是在第一行崩溃并显示“fatalerror:在展开可选值时意外发现nil”我的Swift代码:ifleterror=object.generateModelForm(){println("Error:\(error)")}else{println("Successfullygeneratedmodelf

ios - 如何在 swift 中使用 Key Value Observer?

为了我的目的,我设置了AVFoundation来拍照,我想确保在保存imagedata之前完成曝光和白平衡(adjustingExposure,adjustingWhiteBalance)的调整。否则第一张照片会显得很暗。如何设置键值观察器以在值更改后运行代码?以及如何/在哪里是启动它的最佳地点? 最佳答案 在你得到图像后用didSet创建一个var并且那个var保存图像例如varimage:UIImage{//orwhattypeyourimageis,MabyNSData,butI'mnotsuredidSet{//adjust

ios - UIButton 中的 Swift 3D Touch Force Value

如何测量应用于UIButton功能的3D触摸力?我想用它来快速更改AVAudioPlayer属性的音量。 最佳答案 您可以为所有UIView类\子类使用识别3D触摸的东西自定义类classcustomButton:UIButton{overridefunctouchesMoved(touches:Set,withEventevent:UIEvent?){fortouchintouches{print("%Touchpressure:\(touch.force/touch.maximumPossibleForce)");}}overr

swift - "Cannot assign value of type ' 整数 ' to type ' 单位 ' "

letexpdate=NSUserDefaults.standardUserDefaults().objectForKey("expiration")as!NSDateletcalendar=NSCalendar.currentCalendar()letcomponents=calendar.components([.Day,.Month,.Year],fromDate:expdate)vartheyear=components.yearvarthemonth=components.monthstripCard.expMonth=themonthstripCard.expYear=th

ios - 我如何获得 uibezierPath 的面积和周长,因为 fill() 方法使用了封闭区域

因为UIBeizerPath支持fill()来填充封闭区域。我的要求是如何从UIBeizerPath()获取封闭区域,与fill()方法使用的相同。如果我能在求beizerpath的面积和周长方面得到帮助,我将不胜感激。假设我想获取字母“A”中的封闭区域,我可以获得所有beizerPathCGPoints但无法定义子路径,因为evenOdd规则用于获取所需的字段属性,最后得到面积。我很好奇fill()是如何得到封闭区域的。我得到了字体的beizerPathsolution并希望获得由此绘制的任何字体的区域。我怎样才能做到这一点。 最佳答案