在tableviewcontroller中增加了个UINavigationBar,但是总是跟着tableview一块滚动,怎么才能固定在屏幕的最上方,不跟着tableview一块滚动了
添加UINavigationBar的代码如下    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(buttonPress:)];
    UINavigationItem* navItem = [[UINavigationItem alloc]init];
    navItem.rightBarButtonItem = item;
    navItem.title = @"患者列表";
    UINavigationBar *naviBar = [[UINavigationBar alloc]init];
    naviBar.items = [NSArray arrayWithObject:navItem];
    naviBar.frame = CGRectMake(0.0, 0.0, self.view.frame.size.width, 44.0);
    [self.tableView addSubview:naviBar];
    [navItem release];
    [naviBar release];

解决方案 »

  1.   

    你这个BAR 是直接加在tableview上的,当然滑动啊。
      

  2.   


    我加在view上也不行啊
    [self.view addSubview:naviBar];
      

  3.   

    建议换一种实现方式,在UINavigationController上加一个UITableView。
      

  4.   

    1 你把self.tableview.center向下移动44个像素,正好是一个tablebar的高度;
    2 创建一个tablebar,加在self.view上。
      

  5.   


    就是说,要加在最基础的那个View上。不会出现你说的问题。
      

  6.   

    不行你就在最上边加个view 然后自己添几个按钮。看上去一样的。