(转)处理ios6到ios7后UITableView的两个显示问题

来源:互联网 发布:2016开淘宝卖什么好 编辑:程序博客网 时间:2024/06/05 21:16

1.在ios6开发的项目,当用ios7的虚拟机显示的时候会出现UINavigationItem遮挡TableView的问题:

下面是对比显示效果:




我的处理方法是:

在UITableViewController 的viewwillapper方法中加入以下代码:

 

[objc] view plaincopyprint?
  1. (void)viewWillAppear:(BOOL)animated  
  2.  
  3.     [super viewWillAppear:animated];  
  4.     if([self respondsToSelector:@selector(edgesForExtendedLayout)])  
  5.         [self setEdgesForExtendedLayout:UIRectEdgeBottom];  
  6.  


 

2.ios7还有一个问题是UItableview的第一个section会离头部很大的距离:会出现下面的情况:





原因和ios7的设计有关

有两种方法可以解决,大家可以试一下:

如果你的TableView没有刷新的话可以用下面的代码解决:

在viewWillLoad中添加:

 

[objc] view plaincopyprint?
  1. //设置header of section grouped  
  2.     self.tableView.tableHeaderView [[UIView alloc] initWithFrame:CGRectMake(0.0f0.0fself.tableView.bounds.size.width10.f)];  

如果TableView会刷新页面可以在:viewWillApper中添加相同功能代码:

 

 

[objc] view plaincopyprint?
  1. CGRect frame self.tableView.tableHeaderView.frame 
  2.   frame.size.height 10 
  3.   UIView *headerView [[UIView alloc] initWithFrame:frame];  
  4.   [self.tableView setTableHeaderView:headerView];  

页面就会显示正常。

 



原文地址:http://blog.csdn.net/wildcatlele/article/details/15507111

0 0
原创粉丝点击