Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic UITableView Cell Heights Programmatically IOS7 in Swift

I've been facing the problem since i decided to support IOS7, i was using heightForRowAtIndexPath to return UITableViewAutomaticDimension which is working well only with IOS8. and since UITableViewAutomaticDimensiondoesn't work with IOS7 so i have to handle it manually. but there is no such resource to help in swift about this issue.

i am using custom cell called "Card Cell" :

class CardCell: UITableViewCell {

    @IBOutlet var mainView: UIView!
    @IBOutlet weak var text1: UILabel!
    @IBOutlet weak var sharefb: UIButton!

}

so if there is anyway to handle it in heightForRowAtIndexPath manually using swift ?

like image 923
AaoIi Avatar asked Sep 18 '26 09:09

AaoIi


1 Answers

In iOS 7 you need to implement UITableViewDelegate protocol method and return your cell height.

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return 100.0;
}
like image 135
Sergey Kuryanov Avatar answered Sep 19 '26 22:09

Sergey Kuryanov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!