2012-12-08 31 views
0

我想提出一個UIPickerView對齊UITableView的底部,而不管它滾動的位置。將UIPickerView設置爲UITableview的底部而不考慮滾動位置

當前我有一個UIPickerView添加到我按下按鈕時顯示的UITableView,但是當我滾動表格時,UIPickerView不在視圖中,並且如果我滾動出我已呈現的範圍它,UIPickerView似乎從未被稱爲。

有誰知道如何做到這一點?

感謝

+0

您需要爲UIPickerView設置框架並添加爲self.view的子視圖。不是UITableView的子視圖。 –

回答

0

東西告訴我,必須有我一直在給定的答案更簡單的選擇,我找到了解決辦法。

我決定使用scrollViewDidScroll:找到滾動點的y座標,然後將UIPickerView動畫到所需的位置。

... 
    [UIView beginAnimations:nil context:NULL]; 
    CGFloat pointY = self.scrollPoint.y; 
    [self.sortPicker setFrame:CGRectMake(0, pointY + 200, 320, 216)]; 
    [UIView commitAnimations]; 
    ... 

因此有必要實施方法停止觸摸滾動如果滾動已經停止UIPickerView纔會出現:

- (void)stopScroll:(UITableView *)tableview 
{ 
    CGPoint offset = tableview.contentOffset; 
    [tableview setContentOffset:offset animated:NO]; 
} 

這將允許您顯示和消除的UIPickerView在在任何特定目的地的任何時刻。

1

使用的UITableViewController是偉大的,除非你需要添加子視圖不與表視圖滾動。它不可能完成。解決方案是使用UIViewController,並添加您自己的表視圖,設置表視圖dataSource和委託協議,並複製基本表視圖控制器管道。

一旦您的視圖控制器再次像普通表視圖控制器一樣工作,您現在可以將子視圖添加到視圖控制器的視圖中,該視圖不會隨該表一起滾動。

0

如果u增加tableview中編程

SearchtableView.frame = CGRectMake(450, 90, 318, 600); 
      SearchtableView = [[UITableView alloc] initWithFrame:CGRectMake(623, 90, 400, 400)style:UITableViewStyleGrouped]; 
      [self.view addSubview:SearchtableView]; 
//belove the tableview// 
//Add UIPickerView to the self.view]// 
相關問題