2012-12-05 142 views
1

所以,這是我的看法:的UITableView不會滾動

enter image description here

,這是我的UITableViewDelegate和DataSource

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    return 1; 
} 

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return 20; 
} 

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"course"]; 
    cell.textLabel.text = [NSString stringWithFormat:@"%i" ,arc4random() % 10]; 
    cell.detailTextLabel.text = [NSString stringWithFormat:@"%i" ,arc4random() % 10]; 
    return cell; 
} 

這是結果:

enter image description here

問題是,UItableView不滾動。決不。我真的不知道爲什麼... 有人可以幫助我嗎?

+0

您在結果中顯示的標題圖像(時鐘),您如何實現該功能?它覆蓋了桌面視圖嗎? – mkral

+0

我以編程方式實現,不,它不覆蓋tableView。 –

+0

那麼如果你確定你編寫的頭文件UIView的框架沒有比預期的大,並且覆蓋了tableview,那麼肯定還有別的東西在進行。你有沒有做過任何改變,你認爲可能是問題? tableview是scrollview的一個子類,所以它應該可以工作。 – mkral

回答

4

我見過類似的事情,在每一次我已經看到了這個問題,這是因爲一些人認爲是捕捉觸摸。

明確地說,請檢查您的視圖層次結構,以查看視圖是否與您的tableView重疊(即使是alpha值爲0.05的視圖也可以識別並摘要觸摸)。

我建議你採取控制器的根視圖,並遞歸調用視圖層次結構來NSLog圖像的大小。

你也可以用你的tableView這樣做:

- (void)bringSubviewToFront:(UIView *)view 
[self.view bringSubviewToFront:self.tableView]; 

如果你的tableview被滾動時的其他每一件事面前,你會知道舒爾一些觀點是捕獲表視圖之前觸摸。

+0

我沒有注意到在頂部的視圖(允許你做一個水平滾動)真的非常棒,我調整了視圖的大小,添加了tableView,現在一切正常! –

1

我試圖達到類似的結果,它適用於我。 嘗試檢查你的選擇

UITableViewOptions

+0

它不工作:( –

+0

我只是試圖達到相同的結果和我的tableview卷軸。你有沒有改變任何默認選項? –

3

試着說self.tableView.userInteractionEnabled = YES;你實現時鐘視圖後。

如果這不起作用,嘗試[self.view bringSubviewToFront:self.tableView];