iPhone对象不可滚动

iPhone对象不可滚动,iphone,Iphone,我有按预期滚动的UITableView。我希望桌子占据80%的空间,我希望在顶部有另一个物体。没什么大不了的。我的问题是,我不希望在表格滚动时顶部的对象滚动。如果您能提供任何帮助/示例,说明如何做到这一点,我们将不胜感激。这在搜索栏中可以看到很多。谢谢 好吧,我有了这个概念,但现在我缺乏执行力。如何在我的rootviewcontroller中添加代码?我尝试了以下内容,看到了两个“标题”,但它们仍然在滚动。我已将它们添加到RootViewController中的viewDidLoad中

我有按预期滚动的UITableView。我希望桌子占据80%的空间,我希望在顶部有另一个物体。没什么大不了的。我的问题是,我不希望在表格滚动时顶部的对象滚动。如果您能提供任何帮助/示例,说明如何做到这一点,我们将不胜感激。这在搜索栏中可以看到很多。谢谢


好吧,我有了这个概念,但现在我缺乏执行力。如何在我的rootviewcontroller中添加代码?我尝试了以下内容,看到了两个“标题”,但它们仍然在滚动。我已将它们添加到RootViewController中的viewDidLoad中

     UIView *containerViewA =
 [[[UIView alloc]
   initWithFrame:CGRectMake(0, 0, 300, 60)]
  autorelease];

 UIView *containerViewB =
 [[[UIView alloc]
   initWithFrame:CGRectMake(10, 60, 300, 60)]
  autorelease];

 UILabel *headerLabelA =
 [[[UILabel alloc]
   initWithFrame:CGRectMake(10, 20, 300, 40)]
  autorelease];

 UILabel *headerLabelB =
 [[[UILabel alloc]
   initWithFrame:CGRectMake(10, 80, 300, 40)]
  autorelease];

 headerLabelA.textColor = [UIColor whiteColor];
 headerLabelA.shadowColor = [UIColor blackColor];
 headerLabelA.shadowOffset = CGSizeMake(0, 1);
 headerLabelA.font = [UIFont boldSystemFontOfSize:22];
 headerLabelA.backgroundColor = [UIColor clearColor];
 headerLabelA.text = NSLocalizedString(@"A", @"");

 headerLabelB.textColor = [UIColor whiteColor];
 headerLabelB.shadowColor = [UIColor blackColor];
 headerLabelB.shadowOffset = CGSizeMake(0, 1);
 headerLabelB.font = [UIFont boldSystemFontOfSize:22];
 headerLabelB.backgroundColor = [UIColor clearColor];
 headerLabelB.text = NSLocalizedString(@"B", @"");


 [containerViewB  addSubview:headerLabelA];
 [containerViewA  addSubview:containerViewB];
 [self.view addSubview:containerViewA];

您需要排列视图层次结构,以便其他对象不在可滚动视图中。所以它应该如下所示

UIView
   |
   |-- UIView - this one won't scroll
   |
   |-- UIScrollView
            |
            |--UITableView

加里的答案已经很好了。我只想详细说明一下

您有一个UIViewControllerA(不应该是UITableVIewController或UIScrollViewController)

然后是UITableView B和UIView C


您可以这样做:
[A.view addSubview:C]
然后
[A.view addSubview:B]
。记住使用正确的框架初始化视图

Gary,我可以看到它在IB中工作,但是当我构建时,我在第二个UIView中看不到项目。我为这个新问题道歉。如果我看不到你的IB项目或代码,就有点难知道出了什么问题。对不起。沃德康,我有点困惑。你的答案和加里的不同。你能详细说明一下吗?谢谢你的时间。这是类似的,但不同的解释,我用代码来做。您仍然具有与主视图屏幕是UIView相同的层次结构,然后在主视图的顶部添加另一个视图作为主视图的子视图。然后在视图A下面添加另一个UITableView(或UIScrollView)。