斗士狗 2013-09-18 19:07 采纳率: 0%
浏览 578
已采纳

为什么在 iOS7中 UITableView 风格组合的顶部会有额外的填充

Starting in iOS7, there is additional space at the top of my UITableView's which have a style UITableViewStyleGrouped.

Here is an example:

enter image description here

The tableview starts at the first arrow, there is 35 pixels of unexplained padding, then the green header is a UIView returned by viewForHeaderInSection (where the section is 0).

Can anyone explain where this 35 pixel amount is coming from and how I can get rid of it without switching to UITableViewStylePlain?

转载于:https://stackoverflow.com/questions/18880341/why-is-there-extra-padding-at-the-top-of-my-uitableview-with-style-uitableviewst

  • 写回答

29条回答 默认 最新

  • MAO-EYE 2013-10-05 05:52
    关注

    I have found the cause of my original bug and created a sample project showcasing it. I believe there is an iOS7 bug.

    As of iOS7, if you create a UITableView with the Grouped style, but do not have a delegate set on first layout, then you set a delegate and call reloadData, there will be a 35px space at the top that will never go away.

    See this project I made showcasing the bug: https://github.com/esilverberg/TableViewDelayedDelegateBug

    Specifically this file: https://github.com/esilverberg/TableViewDelayedDelegateBug/blob/master/TableViewDelayedDelegateBug/ViewController.m

    If line 24 is active,

    [self performSelector:@selector(updateDelegate) withObject:nil afterDelay:0.0];
    

    there will be an extra 35 px space at the top. If line 27 is active and 24 is commented out,

    self.tableView.delegate = self;
    

    no space at the top. It's like the tableView is caching a result somewhere and not redrawing itself after the delegate is set and reloadData is called.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(28条)

报告相同问题?

悬赏问题

  • ¥30 vb net 使用 sendMessage 如何输入鼠标坐标
  • ¥200 求能开发抖音自动回复卡片的软件
  • ¥15 关于freesurfer使用freeview可视化的问题
  • ¥100 谁能在荣耀自带系统MagicOS版本下,隐藏手机桌面图标?
  • ¥15 求SC-LIWC词典!
  • ¥20 有关esp8266连接阿里云
  • ¥15 C# 调用Bartender打印机打印
  • ¥15 我这个代码哪里有问题 acm 平台上显示错误 90%,我自己运行好像没什么问题
  • ¥50 C#编程中使用printDocument类实现文字排版打印问题
  • ¥15 找会编程的帅哥美女 可以用MATLAB里面的simulink编程,用Keil5编也可以。