zoukankan      html  css  js  c++  java
  • 如何在UITableViewController上添加一个固定的视图

     最近在使用UITableViewController,想在上面添加一个固定的视图,不随ScrollView滑动而移动.最后找到2种解决办法,一种是计算TableView的偏移,调整视图的位置,不断更新视图,从而达到相对静止.使用UIScrollViewDelegate里的方法-(void) scrollViewDidScroll;

    -(void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
        self.hud.frame = CGRectMake(self.hud.frame.origin.x,self.tableView.contentOffset.y, self.hud.frame.size.width, self.hud.frame.size.height);
    }

    还有一种办法是将视图添加到window上,不过使用这种方法,TableView是不能滑动的.

    - (void)setMBProgressHD{
        self.hud = [[MBProgressHUD alloc]initWithView:self.view];
        AppDelegate *delegata = [[UIApplication sharedApplication] delegate];
        [delegata.window addSubview:self.hud];
        self.hud.labelText = @"Loading...";
        [self.hud show:YES];
    }

     stackOver:http://stackoverflow.com/questions/7537858/iphone-need-to-put-uiview-on-top-of-uitableview-in-fixed-position

  • 相关阅读:
    StringBuild
    String 字符串
    win7 64位支持的最大内存
    Spring获取对象与java new对象区别
    生成随机数
    java String转base64
    java时间格式
    Bash Scripting Learn Notes
    Linux parent process and child process when 'sudo'
    Linux services, runlevels, and rc.d scripts
  • 原文地址:https://www.cnblogs.com/zuopeng/p/4269153.html
Copyright © 2011-2022 走看看