Just Read the Slides

My brother and I have been pitching Clambake... a lot. Recently, the team of advisors at GCH Partners took us on to help accelerate business strategy and customer development.

One of the first things they did with us was a 'pitch bootcamp'. They essentially went through every aspect of our standard presentation and fine-tuned it. They put an emphasis on brevity, clarity and some sizzle.

During one practice pitch, I was in the middle of explaining our core technology, and Greg stopped me suddenly. He said something along the lines of:

"Look, I'm not even listening to you right now. You're talking and I'm reading what's on the slide. Let's read each slide out loud before you talk about it."

I studied speech communication in college, and I'm pretty sure the first thing they told us was, "don't read your PowerPoint slides." So my initial reaction was negative.

However, I took a moment to think back on some of the issues we've had with earlier pitches. People don't pay attention; I assumed that was human nature, but perhaps they were just reading our slides instead of listening.

Greg's point was this:

  • Your audience is going to read what's on the slide.
  • They will tune you out while they're reading it.
  • Therefore, take 10 seconds to read exactly what's on the slide.... and then talk about it.
Read more...

iOS 7: Interactive Pop Gesture With Custom Back Button

Clambake for iPhone has a custom back button on all its navigation bars; it's a simple chevron with no text. The easiest way to implement a custom button like this is to simply set a leftBarButtonItem on the controller's navigationItem.

- (void)viewDidLoad
{
  self.navigationItem.leftBarButtonItem = [self backButton];
}

- (UIBarButtonItem *)backButton
{
  UIImage *image = [UIImage imageNamed:@"back_button"];
  CGRect buttonFrame = CGRectMake(0, 0, image.size.width, image.size.height);

  UIButton *button = [[UIButton alloc] initWithFrame:buttonFrame];
  [button addTarget:self action:@selector(backButtonPressed) forControlEvents:UIControlEventTouchUpInside];
  [button setImage:[UIImage imageNamed:normalImage] forState:UIControlStateNormal];

  UIBarButtonItem *item; = [[UIBarButtonItem alloc] initWithCustomView:button];

  return item;
}

However, doing this nixes the sweet interactive pop gesture iOS 7 provides. I found a quick fix for that here.

Through my beta testers, I started receiving crash reports centering around this gesture pop behavior. I found that by panning left really quickly after pushing a new controller to the stack would cause the crash. In other words, if the user immediately tries to swipe back while the push is still in progress, the navigation controller soils itself.

I found this in the debugger log:

nested pop animation can result in corrupted navigation bar

After a few hours of wrestling with various solves, I found that I can mitigate the errors like this:

Set the gesture delegate to the navigation controller

Like Stuart Hall talks about in his post, assiging a delegate to the gesture resurrects it's behavior when a custom back button is applied. However, with really fast user pop interactions, the controller is sent a message from the gesture after it's been deallocated.

My solution is to simply make the navigation controller itself be the gesture delegate. This technique works best with a UINavigationController subclass.

@interface CBNavigationController : UINavigationController <UIGestureRecognizerDelegate>
@end

@implementation CBNavigationController

- (void)viewDidLoad
{
  __weak CBNavigationController *weakSelf = self;

  if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)])
  {
    self.interactivePopGestureRecognizer.delegate = weakSelf;
  }
}

@end

Disable interactivePopGestureRecognizer during transitions

When the user starts swiping backwards in the middle of a transition, the pop events stack up and "corrupt" the navigation stack. My workaround is to temporarily disable the gesture recognizer during push transitions, and enable it again when the new view controller loads. Again, this is easier with a UINavigationController subclass.

@interface CBNavigationController : UINavigationController <UINavigationControllerDelegate, UIGestureRecognizerDelegate>
@end

@implementation CBNavigationController

- (void)viewDidLoad
{
  __weak CBNavigationController *weakSelf = self;

  if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)])
  {
    self.interactivePopGestureRecognizer.delegate = weakSelf;
    self.delegate = weakSelf;
  }
}

// Hijack the push method to disable the gesture

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
  if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)])
    self.interactivePopGestureRecognizer.enabled = NO;

  [super pushViewController:viewController animated:animated];
}

#pragma mark UINavigationControllerDelegate

- (void)navigationController:(UINavigationController *)navigationController
       didShowViewController:(UIViewController *)viewController
                    animated:(BOOL)animate
{
  // Enable the gesture again once the new controller is shown

  if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)])
    self.interactivePopGestureRecognizer.enabled = YES;
}


@end

Welcome to iOS Auto Layout

I've been preparing Clambake for iOS 7. I was disappointed with how the existing build held up in the new OS; broken layout, awkward spacing, clipped text, etc. Along with the new features we had planned for the next release, there was a lot a stuff to do to get it into reasonable shape.

I decided to begin leveraging Auto Layout since:

  • The iOS 7 transition guide insists that we do, and
  • It purportedly makes laying out a UI easier
Read more...

Rectory: Quickly test HTTP redirects

I published a simple gem yesterday called rectory. It's a tool for confirming HTTP response expectations. For instance, if you're replacing a website with a slicker one with better IA, you'll likely need to redirect a lot of the previously indexed pages to their new spots. Rectory helps you confirm that you correctly implemented all your redirects.

The gem came out of a daunting task at FreeAssociation. We were rebuilding a big non-profit site, and I was responsible for just the redirects. There were around 600 pages that needed to be re-routed to new locations. There were some patterns to the redirects which made it easier, but for the most part the client had, by hand, decided where each old page should go. They gave me that information in a big hairy spreadsheet.

Read more...

SDWebImage / UITableViewCell

In one of our earlier Clambake iOS releases, I noticed a peculiar issue with our 'moves' interface. Scrolling really quickly down the feed (UITableView) would result in some cells 'flashing' through the cell images that came before it. It would eventually load the correct image, but clearly something was wrong, and sometimes users would vote on the wrong post erroneously.

The implementation looked like this:

  • Standard table view and reusable cell structure.
  • SDWebImage for downloading and locally caching images from our servers.
Read more...

Why Isn't That Font Working in IE?

I recently emerged from a @font-face rabbit hole where most of the typeface weights I needed were not rendering in IE8 and below.

The typeface itself was proprietary and blacklisted by FontSquirrel so I had convert the fonts myself from OTF to TTF/EOT/SVG/WOFF. I found a good reference on github for how to go about doing all the conversions; I used a mix of fontforge, ttf2eot and Batik's ttf2svg.

Read more...

Alternating UITableViewCell Background Colors

To render cells in a UITableView so that they have alternating background colors, assign the color to the backgroundView property.

Make sure to do it outside of the init conditional. Otherwise, the cells will become the same color once the user starts scrolling around.