您的位置:首页 > 产品设计 > UI/UE

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

2014-04-29 16:47 429 查看
1.在ios6开发的项目,当用ios7的虚拟机显示的时候会出现UINavigationItem遮挡TableView的问题:

下面是对比显示效果:



我的处理方法是:

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

[objc] view
plaincopyprint?





- (void)viewWillAppear:(BOOL)animated  

{  

    [super viewWillAppear:animated];  

      

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000  

  

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)  

  

    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))  

    {  

        if([self respondsToSelector:@selector(edgesForExtendedLayout)])  

            [self setEdgesForExtendedLayout:UIRectEdgeBottom];  

    }  

#endif  

      

      

    //如果是ios6 要手动设置frame的大小  

    if ([[[UIDevice currentDevice]systemVersion]floatValue] < 7.0)  

    {  

         [self.editBagView setFrame:CGRectMake(5, 37, 310, 118)];  

    }  

     

}  

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





原因和ios7的设计有关

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

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

在viewWillLoad中添加:

[objc] view
plaincopyprint?





//设置header of section grouped  

    self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.tableView.bounds.size.width, 10.f)];  

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

[objc] view
plaincopyprint?





CGRect frame = self.tableView.tableHeaderView.frame;  

  frame.size.height = 10;  

  UIView *headerView = [[UIView alloc] initWithFrame:frame];  

  [self.tableView setTableHeaderView:headerView];  

页面就会显示正常。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: