How to Programmatically Remove a Cell From a Static UITableView

There are two different ways to add cells to a UITableView.

The first is by using dynamic prototype cells in your table view. For a dynamic table view, you programmatically arrange the cells and sections of the table view by implementing the UITableViewDataSource protocol in code. Using this method, you can display a variable number of cells and sections at runtime. Read more on How to Programmatically Remove a Cell From a Static UITableView…

A UIStackView Hack for Stacking Child Views Compactly

Before I developed for iOS, I did a lot of Microsoft WPF programming. One of the layouts available on that platform was a WrapPanel.

Microsoft’s WrapPanel is similar to Apple’s UIStackView in that it arranges child elements into a single line that can be oriented horizontally or vertically. There are many differences, but the one I want to focus on is that a WrapPanel will space the content as close together as possible, and the size of the content is determined by its intrinsic content size. Read more on A UIStackView Hack for Stacking Child Views Compactly…

How to Remove Extra Separator Lines in a UITableView

When your UITableView does not have enough data to fill out the length of the screen, it will show empty cells with separators to fill out the screen. I have run into several situations where the extra separator lines are not wanted. If you have run into this yourself, then here is an easy trick to get rid of them that does not require any code. Read more on How to Remove Extra Separator Lines in a UITableView…

How to Use UISearchController to Add Search Your UITableViews

This is a simple tutorial on how to use the new UISearchController to add search capability to your UITableViews. The UISearchController was introduced a couple years ago in iOS 8 to replace the now deprecated UISearchDisplayController. In the new search controller, it is easier to add search to your table views. As of Xcode 8.1, the UISearchController has not been added to Interface Builder, so you have to add it programmatically. Even still, it is pretty easy to work with. Read more on How to Use UISearchController to Add Search Your UITableViews…

Auto Layout Demystified

I was at a local user group recently where the topic of the meeting was one of the hot new cross-platform mobile development options out there (doesn’t really matter which one). There was the usual UIkit bashing, which was expected since the topic was to propose an alternative programming model.

I’m not here to defend UIkit, because I agree that it can use some improvement. However, the speaker did say one thing about Auto Layout that I have heard before and that rubbed me the wrong way.
Read more on Auto Layout Demystified…

Exploring UIStackView Distribution Types

Any time you encounter a new tool in your life, it’s a good idea to test it out to see what it can do. In this post, that’s what I’m going to do with UIStackViews. I’ll explore the different distribution types you can set on a UIStackView to see how they behave. That way, the next time I have a layout problem to solve, I’ll understand the UIStackView’s capabilities.
Read more on Exploring UIStackView Distribution Types…

How to Pass Data to an iOS Container View

After writing my previous post on adding an iOS container view, I received a couple of questions about how to pass data to the container view. This is a great question because the answer is not obvious to a person just learning iOS. In this post, I will show you how to keep a reference to your container view’s view controller to pass data or call functions on it.
Read more on How to Pass Data to an iOS Container View…

Stretch and Fill Content in UIStackView on iOS

I am just getting into the habit of using the new UIStackView on iOS. I find it much easier to use UIStackView to build the majority of the UI, tweaking it when necessary with Auto Layout. Auto Layout is really powerful and flexible, but for simple layouts, it can be tedious.

Recently, one of my co-workers had a layout he wanted to represent with stack views, and the solution wasn’t obvious to us at first. He had a column of UILabels and UITextFields and wanted them to stretch across the screen. There are many ways you can build the layout, but we chose UIStackView because it seemed like the simplest solution and required no code.
Read more on Stretch and Fill Content in UIStackView on iOS…