UITableViewCell with autolayout left margin different on iPhone and iPad

后端 未结 5 945
臣服心动
臣服心动 2020-11-28 19:47

I am using a grouped UITableView with static cells for an options screen/scene. Everything is done in Xcode 6.1 / iOS 8.1.x / Storyboard using Autolayout. Withi

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 19:57

    I had this problem when testing on a iPad Air, OS 10.1.1. The table headers were indented much further than they should have been, and it was even worse in landscape orientation. But they were fine on iphones up to OS 11.

    The surprising solution was the following line of code, just after the table was created (Sorry, I only work in C#, but it's easy to work out Obj-C and Swift equivalents):

    myTableView.SeparatorInset = myTableView.SeparatorInset;
    

    Then everything was indented as it should be!

提交回复
热议问题