How to use Auto Layout to move other views when a view is hidden?

It is possible, but you’ll have to do a little extra work. There are a couple conceptual things to get out of the way first: Hidden views, even though they don’t draw, still participate in Auto Layout and usually retain their frames, leaving other related views in their places. When removing a view from its … Read more

How to get StackPanel’s children to fill maximum space downward?

It sounds like you want a StackPanel where the final element uses up all the remaining space. But why not use a DockPanel? Decorate the other elements in the DockPanel with DockPanel.Dock=”Top”, and then your help control can fill the remaining space. XAML: <DockPanel Width=”200″ Height=”200″ Background=”PowderBlue”> <TextBlock DockPanel.Dock=”Top”>Something</TextBlock> <TextBlock DockPanel.Dock=”Top”>Something else</TextBlock> <DockPanel HorizontalAlignment=”Stretch” VerticalAlignment=”Stretch” … Read more

How to add constraints programmatically using Swift

Do you plan to have a squared UIView of width: 100 and Height: 100 centered inside the UIView of an UIViewController? If so, you may try one of the 6 following Auto Layout styles (Swift 5 / iOS 12.2): 1. Using NSLayoutConstraint initializer override func viewDidLoad() { let newView = UIView() newView.backgroundColor = UIColor.red view.addSubview(newView) … Read more

How do I size a UITextView to its content?

This works for both iOS 6.1 and iOS 7: – (void)textViewDidChange:(UITextView *)textView { CGFloat fixedWidth = textView.frame.size.width; CGSize newSize = [textView sizeThatFits:CGSizeMake(fixedWidth, MAXFLOAT)]; CGRect newFrame = textView.frame; newFrame.size = CGSizeMake(fmaxf(newSize.width, fixedWidth), newSize.height); textView.frame = newFrame; } Or in Swift (Works with Swift 4.1 in iOS 11) let fixedWidth = textView.frame.size.width let newSize = textView.sizeThatFits(CGSize(width: fixedWidth, … Read more

UIScrollView Scrollable Content Size Ambiguity

Updated Nowadays, Apple realized the problem we solved many years ago (lol_face) and provides Content Layout Guide and Frame Layout Guide as part of the UIScrollView. Therefore you need to go through the following steps: Same as original response below; For this contentView, set top, bottom, left, and right margins to 0 pinning them to … Read more

How do I animate constraint changes?

Two important notes: You need to call layoutIfNeeded within the animation block. Apple actually recommends you call it once before the animation block to ensure that all pending layout operations have been completed You need to call it specifically on the parent view (e.g. self.view), not the child view that has the constraints attached to … Read more

Using Auto Layout in UITableView for dynamic cell layouts & variable row heights

TL;DR: Don’t like reading? Jump straight to the sample projects on GitHub: iOS 8 Sample Project – Requires iOS 8 iOS 7 Sample Project – Works on iOS 7+ Conceptual Description The first 2 steps below are applicable regardless of which iOS versions you are developing for. 1. Set Up & Add Constraints In your … Read more

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