---
title: "self sizing cells in iOS7"  
description: "self sizing cells in iOS7"  
author: "Anonymous User"  
published: 2014-10-17  
updated: 2014-10-17  
canonical: https://www.mindstick.com/forum/2409/self-sizing-cells-in-ios7  
category: "iphone"  
tags: ["iphone", "ios", "ios 7"]  
reading_time: 2 minutes  

---

# self sizing cells in iOS7

With the release of iOS8 I have designed my [table view](https://www.mindstick.com/forum/33654/send-table-view-cell-value-on-button-action-in-ios) with cells taking advantage of self sizing cells. But I need my tables to work in iOS7 as well. How do I do that? Is there a way to [check whether](https://www.mindstick.com/forum/157543/write-a-java-program-to-check-whether-a-string-is-a-palindrome) self sizing cells is supported or not in runtime, or can I implement some table [delegate methods](https://www.mindstick.com/forum/33819/getting-cell-index-number-of-collection-view-from-out-side-the-delegate-methods-in-ios) in my [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc) which will not be called in iOS7?\
If I try my table with self sizing cells in iOS7 I get errors on the console like this:\
Unable to simultaneously satisfy [constraints](https://www.mindstick.com/forum/34816/what-is-mapping-constraints-in-database-management-system). Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each [constraint](https://www.mindstick.com/articles/434/constraint-in-sql-server) and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the [documentation](https://answers.mindstick.com/qa/30462/what-is-documentation) for the UIView [property](https://www.mindstick.com/blog/205/property-notification-in-c-sharp) translatesAutoresizingMaskIntoConstraints) ( "<NSLayoutConstraint:0x7fc912d1d5a0 V:|-(>=11)-[UILabel:0x7fc912d13900] (Names: '|':UITableViewCellContentView:0x7fc912d13400 )>", "<NSLayoutConstraint:0x7fc912d1d6b0 V:[UILabel:0x7fc912d13900]-(11)-| (Names: '|':UITableViewCellContentView:0x7fc912d13400 )>", "<NSAutoresizingMaskLayoutConstraint:0x7fc912d24d80 h=--& v=--& V:[UITableViewCellContentView:0x7fc912d13400(0.5)]>")

## Replies

### Reply by Anonymous User

This is the solution I have found thus far, but it requires checking for specific version number rather than capability. You only set UITableViewAutomaticDimension if you have iOS8 or higher as version:\

```
override func viewDidLoad() {    if NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1 {        self.tableView.estimatedRowHeight = 80        self.tableView.rowHeight = UITableViewAutomaticDimension    }}
```

For iOS7 you need to calculate a height for each cell. But if you are on iOS8 you can return UITableViewAutomaticDimension as the height:

```
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    if NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1 {
        return UITableViewAutomaticDimension
    }
    else {
        return 50 // Or whatever calculated value you need for cell height
    }
}
```


---

Original Source: https://www.mindstick.com/forum/2409/self-sizing-cells-in-ios7

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
