zoukankan      html  css  js  c++  java
  • IOS7学习之路二(处理ios6到ios7后UITableView的两个显示问题)

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

    下面是对比显示效果:




    我的处理方法是:

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

    - (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中添加:

    //设置header of section grouped
        self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.tableView.bounds.size.width, 10.f)];

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

      CGRect frame = self.tableView.tableHeaderView.frame;
        frame.size.height = 10;
        UIView *headerView = [[UIView alloc] initWithFrame:frame];
        [self.tableView setTableHeaderView:headerView];

    页面就会显示正常。




    转载请注明:版权所有http://1.wildcat.sinaapp.com/




  • 相关阅读:
    C# WPF – 利用“Attached Property” 把 RoutedEvent 接上 ICommand
    文件输入输出代码
    strcpy()
    heaplog
    单链表范例
    贪吃蛇
    时钟程序
    herizai_CD2所做答案
    6月25日代码
    6月24日代码
  • 原文地址:https://www.cnblogs.com/lixingle/p/3707712.html
Copyright © 2011-2022 走看看