Animating a constraint in Swift

You need to first change the constraint and then animate the update. This should be in the superview. self.nameInputConstraint.constant = 8 Swift 2 UIView.animateWithDuration(0.5) { self.view.layoutIfNeeded() } Swift 3, 4, 5 UIView.animate(withDuration: 0.5) { self.view.layoutIfNeeded() }

Postgres constraint ensuring one column of many is present?

Since PostgreSQL 9.6 you have the num_nonnulls and num_nulls comparison functions that accept any number of VARIADIC arguments. For example, this would make sure exactly one of the three columns is not null. ALTER TABLE your_table ADD CONSTRAINT chk_only_one_is_not_null CHECK (num_nonnulls(col1, col2, col3) = 1); History & References The PostgreSQL 9.6.0 Release Notes from 2016-09-29 … Read more

Why can I create a table with PRIMARY KEY on a nullable column?

Because the PRIMARY KEY makes the included column(s) NOT NULL automatically. I quote the manual here: The primary key constraint specifies that a column or columns of a table can contain only unique (non-duplicate), nonnull values. Technically, PRIMARY KEY is merely a combination of UNIQUE and NOT NULL. Bold emphasis mine. I ran a test … Read more

Adding an one-out-of-two not null constraint in postgresql

You can use a check constraint e.g. constraint chk_education check (schoolName is not null or studiedAt is not null) From the manual: A check constraint is the most generic constraint type. It allows you to specify that the value in a certain column must satisfy a Boolean (truth-value) expression. Edit: Alternative to comply with Pithyless’ … Read more

‘NSInvalidArgumentException’, reason: ‘Unable to parse constraint format’

It looks like that the autolayout visual format parsing engine is interpreting the “.” in your VFL constraint to be a keyPath instead of a key like it’s using valueForKeyPath:. NSDictionaryOfVariableBindings(…) will take whatever your parameter is in the parenthesis and translate it into a literal key with the object as the value (in your … Read more

Scrollview inside constraint layout does not scroll to the bottom of the parent constraint

This layout works in my app. The trick is to set these two attributes in ScrollView: android:layout_height=”0dp” app:layout_constraintBottom_toBottomOf=”parent” The simplified layout from my app: <?xml version=”1.0″ encoding=”utf-8″?> <android.support.constraint.ConstraintLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”match_parent” android:layout_height=”match_parent” android:theme=”@style/ThemeOverlay.AppCompat.Light”> <RelativeLayout android:id=”@+id/linear” android:layout_width=”0dp” android:layout_height=”56dp” android:background=”@color/title” app:layout_constraintLeft_toLeftOf=”parent” app:layout_constraintRight_toRightOf=”parent” app:layout_constraintTop_toTopOf=”parent” /> <ScrollView android:layout_width=”0dp” android:layout_height=”0dp” app:layout_constraintBottom_toBottomOf=”parent” app:layout_constraintLeft_toLeftOf=”parent” app:layout_constraintRight_toRightOf=”parent” app:layout_constraintTop_toBottomOf=”@id/linear”> <android.support.constraint.ConstraintLayout android:layout_width=”match_parent” android:layout_height=”wrap_content”> <TextView android:id=”@+id/titleView” … Read more