2013-02-16 70 views
1

當前正在查看的場景是「RunTestViewController」。正如你所看到的,嵌入了一個段控件。SegmentControl不隨TableView滾動而移動

一切運行良好,segmentcontrol工作,但是當我滾動段控件保持放,並最終在單元格的頂部。

有沒有一種方法將段控制器嵌入到tableview中,以便隨表移動?

table view 感謝,

**編輯:

------------------ **

我加入這個代碼在viewDidLoad中部分:

UIView *headerView = [[UIView alloc] init ]; 
    [headerView addSubview:resultsSegment]; 
    self.tableView.tableHeaderView = headerView; 

這允許segmentcontrol當表視圖滾動,這是很大的,但是該段控制是移動現在無法點擊,有什麼想法?

回答

2

你想嵌入一個視圖或控件到tableview中,以便它與tableview一起滾動嗎?您應該將視圖或控件放入tableview標題中。

UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,200)]; 
UISegmentedControl *segmentControl = [[UISegmentedControl alloc] initWithFrame:CGRectMake(0, 0, 200, 44)]; 
[headerView addSubview:segmentControl]; 
self.tableView.tableHeaderView = headerView; 
+0

是的,我想嵌入一個控件到表視圖,所以它也滾動。我會給你說的去一個並回復你 – 2013-02-16 23:13:56

+0

我已經更新了我的開幕帖子的詳細信息,謝謝你的幫助 – 2013-02-16 23:20:49

+0

如果我的回答有幫助,請你用答案選中標記來標記它嗎?我花了很多時間試圖回答問題以提高我的聲譽。當然,如果你需要,我很高興幫助你。 – 2013-02-16 23:35:58