---
title: "#197: When UIViews Suddenly Disappear 🐦"
url: https://littlebitesofcocoa.com/197-when-uiviews-suddenly-disappear
author: Jake Marsh
published: 2016-02-23
topics: ["UIKit","Techniques","Debugging"]
description: "It happens to the best of us. We're going along, composing some UIViews in our app. We're styling them, configuring them, we can't wait to try them out."
---

# #197: When UIViews Suddenly Disappear 🐦

By Jake Marsh, February 23, 2016. HTML: https://littlebitesofcocoa.com/197-when-uiviews-suddenly-disappear

It [happens](https://twitter.com/jakemarsh/status/701916519815475200) [to](https://twitter.com/jakemarsh/status/701916707246338048) [the](https://twitter.com/jakemarsh/status/701916729371308032) [best](https://twitter.com/jakemarsh/status/701920237730410496) of [us](https://twitter.com/jakemarsh/status/701923457886396416). We're going along, composing some **UIViews** in our app. We're styling them, configuring them, we can't wait to try them out. That's when we see it. A big, <i>empty,</i> unescapable void of nothingness **right** where our **views** should be! 😱

Today we'll look at some tips to solve a case of _missing_ _UIViews_.

First, we should arm ourselves with tools to help inspect what's going on. **Xcode's** own [View Debugger](https://www.youtube.com/watch?v=KUjbhGOV7DM) is a great place to start, and [Reveal.app](http://revealapp.com/) is a fantastic third-party solution.

Whether it's one of these tools, or simply writing some in-depth **logging functions**, our first step should be to look at both our **view hierarchy** and its **layout** for anything funky.

``` swift
print(UIApplication.sharedApplication().keyWindow?
  .performSelector("recursiveDescription"))
```

We can use **private functions** like `recursiveDescription` to print out a handy <i>tree-view</i> of our **views** to **Xcode's** **Console.**

Most of these debugging sessions stop here, as the problem often involves a **view** not being in the correct place in the hierarchy, or **Auto Layout** has gone and done something wacky with our **views'** locations.

If we're still stuck though, here are some sanity checks we can perform:

- Are any **views** <i>hidden</i>?
- How about <i>transparent</i>? (0 alpha)
- Is it <i>masked</i> via a `maskLayer`?
- Does it have a `CGRectZero` **frame**?
- Is the key **UIWindow** a weird size or in a weird place?

Try making each **view** a <strong><span style='color: #82A160'>specific</span> <span style='color: #BC0FE0'>ugly</span> <span style='color: #A99E1C'>color</span></strong> (the static <i>.XColor()</i> functions on UIColor work wonders here).

- Is another **view** covering it up?
- Is `.clipsToBounds` enabled and a strange **frame**/**bounds** is causing the **view** to be clipped?

If all else fails, comment out everything, and add it back one bit at a time until something fails.

Happy 🐞 hunting!
