草庐IT

iOS 8 : Autorotation is not working without storyboard

所以我试图开始一个没有Storyboard的项目,但我似乎无法弄清楚为什么UIWindow没有将自动旋转命令传递给RootViewController。使用Storyboard,自转有效。如果我以编程方式创建窗口,则自动旋转不起作用。这就是我在AppDelegate中实例化窗口的方式:window=UIWindow(frame:UIScreen.mainScreen().bounds)ifletwindow=window{window.backgroundColor=UIColor.whiteColor()window.makeKeyAndVisible()letnc:SignInVi

ios - xcodebuild no such module 'SwiftyJSON' while build in xcode works

在我的项目中,我使用的是CocoaPods,podfile如下所示:defshared_podsuse_frameworks!pod'SwiftyJSON','~>3.1.4'pod'Alamofire','~>4.3.0'pod'PromiseKit','~>4.4'endtarget'myop'doshared_podsend通过xcode构建工作正常,但如果我尝试通过命令行(xcodebuild工具)构建,我会收到以下错误:error:nosuchmodule'SwiftyJSON'importSwiftyJSON我尝试重新安装SwiftyJSON并将其升级到新版本。还尝试手动将

ios - 自动布局 : Update constraints on UICollectionViewCell doesn't work

我在尝试更新collectionViewCell上的UILabel约束时遇到问题。我的原型(prototype)单元看起来像:我的目标是:我需要编辑红色标签顶部约束的常量,具体取决于我是否隐藏绿色标签。我是如何进行的?我为红色标签(带有红色箭头的标签)上的约束添加了一个IBoutlet:@IBOutletweakvardescriptionTopToPrice:NSLayoutConstraint!然后:descriptionTopToPrice.constant=2self.contentView.setNeedsUpdateConstraints()但它不起作用,并且约束不更新。我

swift - 类型(: ) in Swift 3 does not seem to work with the is type check

这个问题在这里已经有了答案:Swiftdynamictypecheckingforstructs?(2个答案)关闭6年前。type(of:x)在Swift3中似乎不适用于is类型检查它只是给出了这个错误信息:Consecutivestatementsonalinemustbeseparatedby';'代码示例:classTest:UIViewController{}lettest=Test()lettest2=Test()letisEqual=test2istype(of:test)//thisdoesnotcompile这里有什么问题?如何在Swift3中进行这样的动态类型检查?

iOS 9 : Gesture Recognizer was setup in a storyboard/xib to be added to more than one view (not working)

使用iOS9并遇到UITapGestureRecognizer问题。我有一个带有UITableView的ViewController-A。我添加了一个带有textLabel的tableViewCell。我想在textLabel上实现点击。因此,如果我点击textLabel——它应该在控制台上打印或执行任何其他操作问题:TapRecogniser不工作。出现以下错误:以下是我所做的:1)在textLabel(来自StoryBoard)上添加了一个“UITapGestureRecognizer”。为textLabel启用了用户交互(现在仍然是错误)2)下面是IBAction:@IBActi

swift - 值(forKey :) for NSObject not working in Swift 4

在Xcode9Beta中试用Swift4。由于某些原因,在NSObject上使用键值访问器时我遇到了崩溃。有什么想法吗?importCocoaclassPerson:NSObject{varname=""varage=0}letalpha=Person()alpha.name="Robert"alpha.age=53alpha.value(forKey:"name")//error:Executionwasinterrupted,reason:EXC_BAD_INSTRUCTION(code=EXC_I386_INVOP,subcode=0x0). 最佳答案

ios - Swift 泛型 : IntegerType Version Works But Not FloatingPointType

我使用Swift泛型输入了两个版本的离散卷积算法。整数版本有效。但是浮点版本有乘法的问题:importFoundationimportSwiftfunclinconv(signal_Asignal_A:[T],signal_B:[T])->[T]?{//guardguardsignal_A.isEmpty==false&&signal_B.isEmpty==falseelse{returnnil}//reverseatleastoneofthearrays//letsignal_A_reversed=Array(signal_A.reverse())//sizeofnewarrayle

ios 网址(字符串 : ) not working always

lettesturl="http://akns-images.eonline.com/eol_images/Entire_Site/2018029/rs_1024x759-180129200032-1024.lupita-nyongo-angela-bassett-black-panther-premiere.ct.012918.jpg?fit=inside|900:auto"ifleturl=URL(string:testurl){print("valid")}else{print("invalid")}这将打印为无效的URL。但在网络浏览器中显示图像。我见过很多方法,但它会抛出Ap

ios - UIDevice.current.setValue(value, forKey : "orientation") does not work if phone held in landscape and tilted 45 - 90 degrees

我在用letvalue=UIInterfaceOrientation.landscapeRight.rawValueUIDevice.current.setValue(value,forKey:"orientation")强制呈现ViewController以横向显示。这是导航Controller流程的一部分。这按预期工作,但如果手机横向放置并倾斜45到90度,View将以纵向显示。该方法被调用并且预期值是正确的,但景观没有发生变化。这可以在带有导航Controller的基本项目中重现。有谁知道是什么导致了这种行为? 最佳答案 我也

ios - 火力地堡/iOS : runTransactions sometimes doesn't work

我正在开发一个聊天应用程序,用户应该在其中收到有关来自其联系人的新消息的通知。此通知消息还应包括未读消息的数量。因为发送方和接收方都可以更新此信息runTransaction是首选。不幸的是,有时它不起作用。它感觉“卡住”,然后在一段时间后再次开始工作。privateChats节点(见下文)始终使用最新消息进行更新,但openChatMessages节点不会。如果在短时间内发送许多消息,是否会发生这种情况,即runTransactions对相同的ref执行得太频繁?我的数据结构:privateChats$userId$chatId$messageIdtexttimestampsende