iOS tip: Center UILabel in tableFooterView

If you’re building an app that supports portrait and landscape you will probably run into an issue with keeping things centered after device rotation. Below is a quick example of adding a UILabel to a UITableView’s footer and keeping it centered regardless of device rotation. The trick is to use autoresizingMask which does all the magic for you. 😉

, , ,

  • Perry

    That right there is a gem. Thanks a ton.

  • guest

    this is not 100% correct. You are not centering anything, just anchoring the label to left and right sides and take advantage of the centertext feature of the UILabel.
    Replace the label with a View with some content in it and this is not gonna work anymore.

  • guest

    would be nice to actually center the label, without changing its dimensions and using centertext