简体   繁体   中英

Click custom UITableViewCell the label constraint missed

I made a custom tableViewCell in my tableView, the cell using auto layout and in my view controller I used

self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 61.5; 

to compute cell height, every thing is perfect but when I click it, the selection style will let it be wrong like the following picture.

Correct layout like this

After selection had the wrong layout like this

The different between these two picture is the constraints(gap) of title label and time label was missing.

When I change the selection style to UITableViewCellSelectionStyleNone , this bug doesn't happening.

Is their have some solution can fix this problem without disable the selection style? Or something setting missed when I using auto layout result to this problem?

Thanks for everyone!

well what your doing is specify that you want a distance of 7 between the bottom and the label time I guess there is a vertical space between the title and the time label too , if after you change the height of the cell , the constraint stay and get into an undetermined state . What You can do is to change the priority of the constraint (the one you can accept to change ) you can see the priority by clicking on the constraint with the Utilities (the right side menus in Xcode) , and give the constraint an inferior priority like 500 , you can also change the relation of the constraint , (change to equals to greater than or equals)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM