constraints

ios auto-layout: Programmatically set width constraint

拈花ヽ惹草 提交于 2019-12-01 02:52:37
I am working on an ios application. I am adding the auto-layout programmatically to 2 labels. I need to add a constraint to make them equal width. I know how to fix the width of a label by using : constraint = [NSLayoutConstraint constraintWithItem:myLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem: nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0f constant:200.0f]; That would fix the label size to a constant. But I have 2 labels and I want them to have equal size without having to set a constant. Youssef It turned out I just have to do the following:

Alter a nonunique index to a unique index

点点圈 提交于 2019-12-01 02:47:53
I have a few non-unique constraints that I want to alter into unique constraints ( business rules have changed since the data model was made ). Is there any way to do it with out dropping and recreating as a unique constraint? I was thinking there would be an option in the alter constraint command, but I have not found anything. Thanks!! You can't modify a constraint in the way you wish you can only drop and recreate it. If you want to do this with no downtime then look into the DBMS_REDEFINITION package. You cannot convert a non-unique index into a unique index. (It's difficult to say what

UITableView auto resizing row constraint breaking mysteriously on iPhone 6Plus

好久不见. 提交于 2019-12-01 02:42:56
I have a custom UITableViewCell which has a thumbnail and bunch of text. The row height is configured to be calculated automatically using tableView.estimatedRowHeight = 129; tableView.rowHeight = UITableViewAutomaticDimension The row height should be calculated as exactly 138 points. Everything looks great on the iPhone 5. However, on iPhone 6 Plus, the auto row height fails INTERMITTENTLY for random rows with the following log. ( "<NSLayoutConstraint:0x17009ddd0 V:|-(20)-[scoop.ThumbnailImage:0x124d2a5a0] (Names: '|':UITableViewCellContentView:0x124e23200 )>", "<NSLayoutConstraint

Programmatically Added Constraint Not Working

时光总嘲笑我的痴心妄想 提交于 2019-12-01 02:27:24
问题 I've been trying to add constraints programmatically to a view that I'm also adding programmatically to my view controller. However, it seems like the constraints are not being followed. The view has been added to the story board for the view controller, but isn't actually added to the view controller's view until later on (See screenshot below). I've tried adding a variety of constraints but none of them have worked so far. I've simplified it now to the single constraint below and even this

deferred constraint checking

北城以北 提交于 2019-12-01 02:22:10
问题 Currently In our database design we have an circular reference between two entities. In other words, we have foreign keys in each table that reference each others primary key. In order to insert records in these tables we need to perform a deferred constraint checking. Is this possible in SQL Server 2008? I know Oracle DDL has special syntax for this. 回答1: There is no native way to do deferred constraint checking in SQL Server. Likely your best option is to insert a NULL value into the

In SQL Server 2005, how do I set a column of integers to ensure values are greater than 0?

本秂侑毒 提交于 2019-12-01 01:32:36
问题 This is probably a simple answer but I can't find it. I have a table with a column of integers and I want to ensure that when a row is inserted that the value in this column is greater than zero. I could do this on the code side but thought it would be best to enforce it on the table. Thanks! I was in error with my last comment all is good now. 回答1: You can use a check constraint on the column. IIRC the syntax for this looks like: create table foo ( [...] ,Foobar int not null check (Foobar >

MySQL composite unique on FK's

℡╲_俬逩灬. 提交于 2019-12-01 00:35:23
I want to implement the following constraints in mysql: create table TypeMapping( ... constraint unique(server_id,type_id), constraint foreign key(server_id) references Server(id), constraint foreign key(type_id) references Type(id) ); This throws a 'ERROR 1062 (23000): Duplicate entry '3-4' for key 'server_id'' when I issue an insert/update that would break the constraint. Is this type of constraint even possible? If so how? Thank you. Yes, that is perfectly valid. Make sure you understand that the composite unique constraint will only break when you try to insert a new row in TypeMapping ,

Struggling with simple constraints in constrOptim

我们两清 提交于 2019-12-01 00:12:06
I have a function in R that I wish to maximise subject to some simple constraints in optim or constrOptim , but I'm struggling to get my head around ci and ui to fit my constraints. My function is: negexpKPI <- function(alpha,beta,spend){ -sum(alpha*(1-exp(-spend/beta))) } where alpha and beta are fixed vectors, and spend is a vector of spends c(sp1,sp2,...,sp6) which I want to vary in order to maximise the output of negexpKPI . I want to constrain spend in three different ways: 1) Min and max for each sp1,sp2,...,sp6 , i.e 0 < sp1 < 10000000 5000 < sp2 < 10000000 ... 2) A total sum: sum(spend

Displaying the constraints in a table

谁都会走 提交于 2019-12-01 00:01:17
问题 Hello I am trying to display the constraints in one of my tables but for some reason I get the message no rows selected. Noted below is the table I have created. Create table Teams ( TeamID varCHAR2(4) constraint Teams_TeamID_PK Primary Key, TeamName VARCHAR2(40) ); This is the code I am using to show my constraints. SELECT constraint_name, constraint_type, search_condition FROM USER_CONSTRAINTS WHERE table_name = 'Teams'; I am a rookie so I want to make sure I understand what is wrong. I

MSSQL: Update statement avoiding the CHECK constraint

烈酒焚心 提交于 2019-11-30 22:47:39
Working in MS2000, I have a table called JobOwners that maps Jobs (JPSID) to the Employees that own them (EmpID). It also contains the date they started owning that job (DateStarted), date they stopped owning that job (DateEnded) and if the ownership is active (IsActive). Looks like this. CREATE TABLE JobOwners ( LogID int NOT NULL IDENTITY(1,1) PRIMARY KEY, JPSID int NOT NULL FOREIGN KEY REFERENCES JobsPerShift(JPSID), EmpID int NOT NULL FOREIGN KEY REFERENCES Employees(EmpID), DateStarted datetime, DateEnded datetime, IsActive tinyint NOT NULL ) There should be no duplicates of JPSID that