How can I create UIStackView with variable spacing between views?

Update For iOS 11, StackViews with Custom Spacing Apple has added the ability to set custom spacing in iOS 11. You simply have to specify the spacing after each arranged subview. Unfortunately you can’t specify spacing before. stackView.setCustomSpacing(10.0, after: firstLabel) stackView.setCustomSpacing(10.0, after: secondLabel) Still way better than using your own views. For iOS 10 and … Read more

Swift default AlertViewController breaking constraints

The following removes the warning without needing to disable animation. And assuming Apple eventually fixes the root cause of the warning, it shouldn’t break anything else. extension UIAlertController { func pruneNegativeWidthConstraints() { for subView in self.view.subviews { for constraint in subView.constraints where constraint.debugDescription.contains(“width == – 16”) { subView.removeConstraint(constraint) } } } } This can then … Read more

What is ‘Vary for Traits’ in Xcode 8?

This is just an extension as to how to use “Vary Traits” quickly in your project for adding different layouts for iPad and iPhones. Please read this for understanding more on the Size classes. https://developer.apple.com/reference/uikit/uitraitcollection If you are skipping the example which follows below, do read the Summary in the end. OBJECTIVE : You need … Read more

How to adjust height of UICollectionView to be the height of the content size of the UICollectionView?

I would suggest the following: Add a height constraint to your collection view. Set its priority to 999. Set its constant to any value that makes it reasonably visible on the storyboard. Change the bottom equal constraint of the collection view to greater or equal. Connect the height constraint to an outlet. Every time you … Read more

UITableView dynamic cell heights only correct after some scrolling

I don’t know this is clearly documented or not, but adding [cell layoutIfNeeded] before returning cell solves your problem. – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { TableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@”TestCell”]; NSUInteger n1 = firstLabelWordCount[indexPath.row]; NSUInteger n2 = secondLabelWordCount[indexPath.row]; [cell setNumberOfWordsForFirstLabel:n1 secondLabel:n2]; [cell layoutIfNeeded]; // <- added return cell; }

What is NSLayoutConstraint “UIView-Encapsulated-Layout-Height” and how should I go about forcing it to recalculate cleanly?

Try to lower the priority of your _collapsedtextHeightConstraint to 999. That way the system supplied UIView-Encapsulated-Layout-Height constraint always takes precedence. It is based on what you return in -tableView:heightForRowAtIndexPath:. Make sure to return the right value and your own constraint and the generated one should be the same. The lower priority for your own constraint … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)