草庐IT

constraint1

全部标签

ios - UIView 没有名为 'setTranslatesAutoresizingMaskIntoConstraints' 的成员

我正在使用Xcode7beta和Swift2我正在尝试通过addController操作将ViewController(childVC)添加到容器中。我想针对容器为ViewController设置自动布局。在下面的代码中,它给出了以下错误UIView没有名为“setTranslatesAutoresizingMaskIntoConstraints”的成员。我也试过将“false”放在方括号中(参见下面的注释行)——但即使那样也行不通我基本上希望childVC占据整个容器。childVC有一个tableview,它应该根据容器大小调整大小。funcaddController(contro

generics - 为什么这个协议(protocol)可以 "only be used as a generic constraint"?

我正在尝试在Swift中执行以下操作:protocolProtocolWithAlias{typealiasT}protocolAnotherProtocol{funcsomeFunc()->ProtocolWithAlias}但我收到错误:Protocol'ProtocolWithAlias'canonlybeusedasagenericconstraintbecauseithasSelforassociatedtyperequirements。有没有可能做这样的事情?错误消息(或者至少是“onlybeusedasagenericconstraint”部分)对我来说似乎没有多大意义。

swift - 为什么我在 xcode 6 beta 中得到 "Must translate autoresizing mask into constraints to have _setHostsLayoutEngine:YES"

我在swiftUITableViewController中有以下代码,但我得到一个“必须将自动调整掩码转换为约束才能在第2行有_setHostsLayoutEngine:YES异常。我没有更改界面构建器中的任何设置(所以自动布局和大小类均已检查)。overridefunctableView(tableView:UITableView!,cellForRowAtIndexPathindexPath:NSIndexPath!)->UITableViewCell?{letcell:TodoItemCell=tableView.dequeueReusableCellWithIdentifier

ios - 获取异常 : "Impossible to set up layout with view hierarchy unprepared for constraint"

在我的Storyboard应用程序中,我尝试向界面添加额外的UITextField。但我得到标题所说的异常(exception)。我用SwiftAutoLayout图书馆。这是我的代码://MARK:-IBOutlets@IBOutletweakvarpasswordTextField:UITextField!//MARK:-PropertiesletuserIdTextField=UITextField()//MARK:-LifecycleoverridefuncviewDidLoad(){super.viewDidLoad()self.passwordTextField.keybo

swift - "Protocol ... can only be used as a generic constraint because it has Self or associated type requirements"是什么意思?

我正在尝试创建一个以Swift中的自定义协议(protocol)为键的字典(实际上是一个HashSet),但它在标题中给出了错误:Protocol'myProtocol'canonlybeusedasagenericconstraintbecauseithasSelforassociatedtyperequirements而且我无法理解它的正反面。protocolObserving:Hashable{}varobservers=HashSet() 最佳答案 协议(protocol)Observing继承自协议(protocol)Ha

C# 泛型 : Constraining T where T : Object doesn't compile; Error: Constraint cannot be special class 'object'

当我用这样的对象约束T时:publicinterfaceIDoWorkwhereT:Object{TDoWork();}我得到错误:Constraintcannotbespecialclass'object'这是否意味着与编译后的以下内容存在隐含差异?publicinterfaceIDoWork//whereT:Object{TDoWork();} 最佳答案 如果要将泛型类型限制为引用类型,请使用:class。publicinterfaceIDoWorkwhereT:class{TDoWork();}这将禁止泛型成为值类型,例如in

c# - 如何让 EF 6 在 INSERT 期间处理数据库上的 DEFAULT CONSTRAINT

我是EF的新手(这是我的第一周),但对数据库或编程并不陌生。其他人也问过类似的问题,但我不觉得它被问到了正确的细节,或者解释得不够清楚,所以我走了。问题:如何让EntityFramework正确处理在执行INSERT时定义了DEFAULTCONSTRAINT的数据库中的列?意思是,如果在插入操作期间我没有在模型中提供值,我如何让EF从其生成的TSQLINSERT命令中排除该列,以便数据库定义的DEFAULTCONSTRAINT可以工作?背景我创建了一个简单的表,只是为了测试EntityFramework6(EF6)及其与SQLServer能够更新的列的交互。这利用了IDENTITY、T

C# 泛型 : what's the point of the "X<T> where T: X<T>" generic type constraint?

读一本书:NHibernate3:Beginnersguide我发现了一个让我很好奇的片段:Timeforaction–Creatingabaseentity(...)AddanewclasstothefolderDomainoftheprojectandcallitEntity.MaketheclassabstractandgenericinT.Yourcodeshouldlooksimilartothefollowingcodesnippet:usingSystem;namespaceOrderingSystem.Domain{publicabstractclassEntitywh

c# - 如何修复 : The number of properties in the Dependent and Principal Roles in a relationship constraint must be identical?

我正在对SQLServer2012数据库使用EntityFramework4.3.1,并且我正在使用POCO方法。我收到以下错误,我想知道是否有人可以解释如何修复它:模型验证异常Oneormorevalidationerrorsweredetectedduringmodelgeneration:\tSystem.Data.Entity.Edm.EdmAssociationConstraint::ThenumberofpropertiesintheDependentandPrincipalRolesinarelationshipconstraintmustbeidentical.没有可用

c# - 我收到错误 "The DELETE statement conflicted with the REFERENCE constraint"

我尝试用外键截断表并收到消息:"CannottruncatetablebecauseitisbeingreferencedbyaFOREIGNKEYconstraint".我阅读了很多有关该问题的文献,并认为我通过使用delete找到了解决方案DELETEFROMtable_nameDBCCCHECKIDENT(table_name,RESEED,0)但我仍然收到错误消息:"TheDELETEstatementconflictedwiththeREFERENCEconstraint".当我尝试使用MicrosoftManagementStudio删除并执行之前的查询时DELETEFRO