2010-06-30 41 views
1

我有UITableView滾動按預期。我希望桌子佔用80%的空間,並且我希望頂部有另一個物體。沒有什麼大不了的。我的問題是,我不希望表格頂部的對象滾動。任何幫助/如何做到這一點的例子將不勝感激。這在搜索欄中看到很多。謝謝。iPhone對象不可滾動


好吧,我明白了,但現在我缺乏執行力了。我怎樣才能在我的rootViewControler中添加代碼?我嘗試了以下,我看到兩個「標題」,但他們仍然都在滾動。我在RootViewController的

 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]; 

回答

2

你需要讓其他對象不是可滾動視圖中安排您的視圖層次將它們添加到我的viewDidLoad中。所以它看起來應該如下所示。

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

Gary, 我可以看到,這在IB中工作,但是當我生成時,我沒有看到第二個UIView中的項目。我對這個新問題表示歉意。 – Daniel 2010-06-30 03:41:42

+0

如果我無法看到您的IB項目或代碼抱歉,要知道發生了什麼問題有點困難。 – Gary 2010-06-30 04:13:59

1

加里的答案已經很好了。我只想闡述它。

你有一個UIViewControler A(不應該是UITableVIewController或UIScrollViewController)。

然後你有一個UITableView B和C. UIView的

你可以這樣做:[A.view addSubview:C],然後[A.view addSubiew:B]。記得用正確的框架初始化視圖

+0

Vodkhang, 我有點困惑。你的答案與加里的不同。你能詳細說明嗎?謝謝你的時間。 – Daniel 2010-06-30 03:51:45

+0

它是類似的,但不同的解釋,我用代碼來做到這一點。您仍然具有與主視圖屏幕是UIView相同的層次結構,然後將其他視圖A添加爲主視圖頂部主視圖的子視圖。然後在視圖A下方添加另一個UITableView(或UIScrollView)。 – vodkhang 2010-06-30 03:58:19